From 49688f8478de5391bc51065299ce3563f5013e67 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 28 Aug 2024 07:59:47 +0200 Subject: [PATCH 1/2] Remove unused PACKAGE_BUGREPORT, initialize FIRMWARE_VERSION with sensible default --- CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1247d8219c..1bb084a4de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,11 +254,8 @@ if(GIT_FOUND) ) endif() -# Below is a hard-coded info -set (FIRMWARE_VERSION "No svn information") -add_definitions("-DFIRMWARE_VERSION=\"${FIRMWARE_VERSION}\"") +add_definitions("-DFIRMWARE_VERSION=\"${GIT_COMMIT_HASH}\"") add_definitions("-DPACKAGE_VERSION=\"Branch: ${GIT_BRANCH} Abrev. Hash: ${GIT_COMMIT_HASH} Date: ${GIT_COMMIT_DATE}\"") -add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"") # Debug related options ######################################### From 8bffd1666df6696407a90594bd293248661ef30e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 28 Aug 2024 09:35:41 +0200 Subject: [PATCH 2/2] Avoid complete rebuild on cmake run with git info change Before this commit, the following will trigger a complete rebuild: - create another git name (git checkout -b test) - run cmake again manually (cmake ..) - run ninja again The top-level CMakeLists.txt uses add_definitions() to add git information to all targets; if some git information changes, this will mark all command lines as dirty, triggering the build. There is an easy solution: instead of passing this information on the command line, pass it in a header. This commit uses configure_file() to generate a file oai_version.h in the build directory with the same information. Various sources files, e.g., main executables, use this to output the same information as before. It is then also not necessary to use header guards, as cmake takes care to create this file. If cmake is re-run, it will update the header, and trigger only files including this header will be rebuilt (which can be shown with the above stpes). The information passed is the same as before, and updates the information when the old method would have updated it. --- CMakeLists.txt | 16 ++----------- common/CMakeLists.txt | 2 ++ common/oai_version.h.in | 32 +++++++++++++++++++++++++ common/utils/DOC/loader/devusage/api.md | 2 +- common/utils/load_module_shlib.c | 3 ++- common/utils/telnetsrv/telnetsrv.c | 6 ++--- common/utils/websrv/CMakeLists.txt | 6 ++--- doc/Doxyfile | 2 +- executables/lte-softmodem.c | 6 ++--- executables/lte-uesoftmodem.c | 6 ++--- executables/main_ru.c | 6 ++--- executables/nr-cuup.c | 6 ++--- executables/nr-softmodem.c | 6 ++--- executables/nr-uesoftmodem.c | 6 ++--- nfapi/open-nFAPI/docs/Doxyfile.in | 2 +- openair1/PHY/CODING/3gpplte_sse.c | 6 ++--- openair3/NAS/UE/nas_ue_task.c | 5 ++-- 17 files changed, 63 insertions(+), 55 deletions(-) create mode 100644 common/oai_version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bb084a4de..152c506f7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,6 @@ set (OPENAIR2_DIR ${OPENAIR_DIR}/openair2) set (OPENAIR3_DIR ${OPENAIR_DIR}/openair3) set (OPENAIR3_DIR ${OPENAIR_DIR}/openair3) set (OPENAIR_CMAKE ${OPENAIR_DIR}/cmake_targets) -set (OPENAIR_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) project (OpenAirInterface) @@ -254,9 +253,6 @@ if(GIT_FOUND) ) endif() -add_definitions("-DFIRMWARE_VERSION=\"${GIT_COMMIT_HASH}\"") -add_definitions("-DPACKAGE_VERSION=\"Branch: ${GIT_BRANCH} Abrev. Hash: ${GIT_COMMIT_HASH} Date: ${GIT_COMMIT_DATE}\"") - # Debug related options ######################################### add_boolean_option(DEBUG_ASN1 False "Enable ASN1 debug logs" OFF) @@ -541,16 +537,8 @@ add_boolean_option(NAS_UE True "NAS UE INSTANCE (<> NAS_MME)" add_boolean_option(RRC_DEFAULT_RAB_IS_AM True "set the LTE RLC mode to AM for the default bearer, otherwise it is UM." ON) # add the binary tree to the search path for include files -####################################################### -# We will find ConfigOAI.h after generation in target directory -include_directories("${OPENAIR_BIN_DIR}") -# add directories to find all include files -# the internal rule is to use generic names such as defs.h -# but to make it uniq name as adding the relative path in the include directtive -# example: #include "RRC/LTE/rrc_defs.h" -#find_path (include_dirs_all *.h ${OPENAIR_DIR}) -#find_path (include_dirs_all *.h PATHS /usr/include NO_CMAKE_PATH) -#include_directories("${include_dirs_all}") +# We will find common/oai_version.h after generation in target directory +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # Legacy exact order diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 512d2b1553..6c2d123397 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1 +1,3 @@ add_subdirectory(utils) + +configure_file(oai_version.h.in oai_version.h @ONLY) diff --git a/common/oai_version.h.in b/common/oai_version.h.in new file mode 100644 index 0000000000..4b54e6fc44 --- /dev/null +++ b/common/oai_version.h.in @@ -0,0 +1,32 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef OAI_VERSION_H_ +#define OAI_VERSION_H_ + +#define GIT_BRANCH "@GIT_BRANCH@" +#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" +#define GIT_COMMIT_DATE "@GIT_COMMIT_DATE@" + +#define OAI_FIRMWARE_VERSION GIT_COMMIT_HASH +#define OAI_PACKAGE_VERSION "Branch: " GIT_BRANCH " Abrev. Hash: " GIT_COMMIT_HASH " Date: " GIT_COMMIT_DATE + +#endif /* OAI_VERSION_H_ */ diff --git a/common/utils/DOC/loader/devusage/api.md b/common/utils/DOC/loader/devusage/api.md index 59623e256b..4fbc8febfa 100644 --- a/common/utils/DOC/loader/devusage/api.md +++ b/common/utils/DOC/loader/devusage/api.md @@ -6,7 +6,7 @@ int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf) * Formats the full shared library path, using the `modname` argument and the loader `shlibpath` and `shlibversion`configuration parameters. * loads the shared library, using the dlopen system call * looks for `< modname >_autoinit` symbol, using the `dlsym` system call and possibly call the corresponding function. -* looks for `< modname >_checkbuildver` symbol, using the `dlsym` system call and possibly calls the corresponding function. If the return value of this call is `-1`, program execution is stopped. It is the responsibility of the shared library developer to implement or not a `< modname >_checkbuildver` function and to decide if a version mismatch is a fatal condition. The `< modname >_checkbuildver` function must match the `checkverfunc_t` function type. The first argument is the main executable version, as set in the `PACKAGE_VERSION` macro defined in the [oai CMakeLists](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/CMakeLists.txt#L218), around line 218. The second argument points to the shared library version which should be set by the `< modname >_checkbuildver` function. +* looks for `< modname >_checkbuildver` symbol, using the `dlsym` system call and possibly calls the corresponding function. If the return value of this call is `-1`, program execution is stopped. It is the responsibility of the shared library developer to implement or not a `< modname >_checkbuildver` function and to decide if a version mismatch is a fatal condition. The `< modname >_checkbuildver` function must match the `checkverfunc_t` function type. The first argument is the main executable version, as set in the `OAI_PACKAGE_VERSION` macro defined in the [`common/CMakeLists`](../../../CMakeLists). The second argument points to the shared library version which should be set by the `< modname >_checkbuildver` function. * If the farray pointer is null, looks for `< modname >_getfarray` symbol, calls the corresponding function when the symbol is found. `< modname >_getfarray` takes one argument, a pointer to a `loader_shlibfunc_t` array, and returns the number of items in this array, as defined by the `getfarrayfunc_t` type. The `loader_shlibfunc_t` array returned by the shared library must be fully filled (both `fname` and `fptr` fields). * looks for the `numf` function symbols listed in the `farray[i].fname` arguments and set the corresponding `farray[i].fptr`function pointers diff --git a/common/utils/load_module_shlib.c b/common/utils/load_module_shlib.c index 15d2b3d852..4fa1b9f357 100644 --- a/common/utils/load_module_shlib.c +++ b/common/utils/load_module_shlib.c @@ -38,6 +38,7 @@ #include #include #include "openair1/PHY/defs_common.h" +#include "common/oai_version.h" #define LOAD_MODULE_SHLIB_MAIN #include "common/config/config_userapi.h" @@ -45,7 +46,7 @@ void loader_init(void) { paramdef_t LoaderParams[] = LOADER_PARAMS_DESC; - loader_data.mainexec_buildversion = PACKAGE_VERSION; + loader_data.mainexec_buildversion = OAI_PACKAGE_VERSION; int ret = config_get(config_get_if(), LoaderParams, sizeofArray(LoaderParams), LOADER_CONFIG_PREFIX); if (ret <0) { printf("[LOADER] configuration couldn't be performed via config module, parameters set to default values\n"); diff --git a/common/utils/telnetsrv/telnetsrv.c b/common/utils/telnetsrv/telnetsrv.c index 46e00e0019..43208748d0 100644 --- a/common/utils/telnetsrv/telnetsrv.c +++ b/common/utils/telnetsrv/telnetsrv.c @@ -56,6 +56,7 @@ #include "common/utils/threadPool/thread-pool.h" #include "executables/softmodem-common.h" #include +#include "common/oai_version.h" #include "telnetsrv_phycmd.h" @@ -938,10 +939,7 @@ int add_telnetcmd(char *modulename, telnetshell_vardef_t *var, telnetshell_cmdde against main exec version. version mismatch not considered as fatal (interfaces not supposed to change) */ int telnetsrv_checkbuildver(char *mainexec_buildversion, char **shlib_buildversion) { -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "standalone built: " __DATE__ __TIME__ -#endif - *shlib_buildversion = PACKAGE_VERSION; + *shlib_buildversion = OAI_PACKAGE_VERSION; if (strcmp(mainexec_buildversion, *shlib_buildversion) != 0) { fprintf(stderr,"[TELNETSRV] shared lib version %s, doesn't match main version %s, compatibility should be checked\n", diff --git a/common/utils/websrv/CMakeLists.txt b/common/utils/websrv/CMakeLists.txt index fd1b216c88..5a54460342 100644 --- a/common/utils/websrv/CMakeLists.txt +++ b/common/utils/websrv/CMakeLists.txt @@ -87,6 +87,6 @@ add_custom_target( add_dependencies(websrv websrvfront) # copy frontend files to a websrv subdirectory of where oai copy all built files add_custom_command(TARGET websrvfront - POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist/softmodem-ngx ${OPENAIR_BIN_DIR}/../websrv - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/helpfiles ${OPENAIR_BIN_DIR}/../websrv/helpfiles - COMMENT "Moving frontend files to:\n ${OPENAIR_BIN_DIR}/../websrv \n " ) + POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist/softmodem-ngx ${CMAKE_CURRENT_BINARY_DIR}/../websrv + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/helpfiles ${CMAKE_CURRENT_BINARY_DIR}/../websrv/helpfiles + COMMENT "Moving frontend files to: ${CMAKE_CURRENT_BINARY_DIR}/../websrv" ) diff --git a/doc/Doxyfile b/doc/Doxyfile index 5ae52a3c3a..5f377964cf 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = OpenAirInterface # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = @GIT_COMMIT_HASH@ (@GIT_BRANCH@) # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index 99f98d4f83..69abbb4464 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -37,6 +37,7 @@ #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all #include "assertions.h" +#include "common/oai_version.h" #include "PHY/types.h" @@ -466,11 +467,8 @@ int main ( int argc, char **argv ) init_opt(); // to make a graceful exit when ctrl-c is pressed set_softmodem_sighandler(); -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" -#endif // strdup to put the sring in the core file for post mortem identification - LOG_I(HW, "Version: %s\n", strdup(PACKAGE_VERSION)); + LOG_I(HW, "Version: %s\n", strdup(OAI_PACKAGE_VERSION)); /* Read configuration */ if (RC.nb_inst > 0) { diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index a75a22fba4..74c63687b0 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -42,6 +42,7 @@ #include "pdcp.h" #include "PHY/defs_UE.h" +#include "common/oai_version.h" #include "common/ran_context.h" #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" @@ -575,11 +576,8 @@ int main( int argc, char **argv ) { pdcp_pc5_socket_init(); // to make a graceful exit when ctrl-c is pressed set_softmodem_sighandler(); -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" -#endif // strdup to put the sring in the core file for post mortem identification - LOG_I(HW, "Version: %s\n", strdup(PACKAGE_VERSION)); + LOG_I(HW, "Version: %s\n", strdup(OAI_PACKAGE_VERSION)); // init the parameters for (CC_id=0; CC_id +#include "common/oai_version.h" #include "PHY/types.h" #include "common/ran_context.h" @@ -644,11 +645,8 @@ int main( int argc, char **argv ) { // initialize mscgen log after ITTI init_opt(); -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" -#endif // strdup to put the sring in the core file for post mortem identification - char *pckg = strdup(PACKAGE_VERSION); + char *pckg = strdup(OAI_PACKAGE_VERSION); LOG_I(HW, "Version: %s\n", pckg); // don't create if node doesn't connect to RRC/S1/GTP diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index bc5f4bc778..47284cd355 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -26,6 +26,7 @@ #include #include "T.h" +#include "common/oai_version.h" #include "assertions.h" #include "PHY/types.h" #include "PHY/defs_nr_UE.h" @@ -430,11 +431,8 @@ int main(int argc, char **argv) if (ouput_vcd) { vcd_signal_dumper_init("/tmp/openair_dump_nrUE.vcd"); } -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" -#endif // strdup to put the sring in the core file for post mortem identification - char *pckg = strdup(PACKAGE_VERSION); + char *pckg = strdup(OAI_PACKAGE_VERSION); LOG_I(HW, "Version: %s\n", pckg); PHY_vars_UE_g = malloc(sizeof(*PHY_vars_UE_g) * NB_UE_INST); diff --git a/nfapi/open-nFAPI/docs/Doxyfile.in b/nfapi/open-nFAPI/docs/Doxyfile.in index 74d405ad00..1120edd8f4 100644 --- a/nfapi/open-nFAPI/docs/Doxyfile.in +++ b/nfapi/open-nFAPI/docs/Doxyfile.in @@ -31,7 +31,7 @@ PROJECT_NAME = @PACKAGE_NAME@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = @PACKAGE_VERSION@ +PROJECT_NUMBER = @GIT_COMMIT_HASH@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/openair1/PHY/CODING/3gpplte_sse.c b/openair1/PHY/CODING/3gpplte_sse.c index 865ffef2d9..c161682f7d 100644 --- a/openair1/PHY/CODING/3gpplte_sse.c +++ b/openair1/PHY/CODING/3gpplte_sse.c @@ -33,6 +33,7 @@ #include #include #include +#include "common/oai_version.h" #include "PHY/sse_intrin.h" @@ -359,10 +360,7 @@ void init_encoder_sse (void) { against main exec version. version mismatch no considered as fatal (interfaces not supposed to change) */ int coding_checkbuildver(char *mainexec_buildversion, char **shlib_buildversion) { -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "standalone built: " __DATE__ __TIME__ -#endif - *shlib_buildversion = PACKAGE_VERSION; + *shlib_buildversion = OAI_PACKAGE_VERSION; if (strcmp(mainexec_buildversion, *shlib_buildversion) != 0) { fprintf(stderr,"[CODING] shared lib version %s, doesn't match main version %s, compatibility should be checked\n", diff --git a/openair3/NAS/UE/nas_ue_task.c b/openair3/NAS/UE/nas_ue_task.c index 33c585bcc3..ac2cc4db16 100644 --- a/openair3/NAS/UE/nas_ue_task.c +++ b/openair3/NAS/UE/nas_ue_task.c @@ -30,6 +30,7 @@ # include "nas_parser.h" # include "nas_proc.h" #include "common/utils/mem/oai_memory.h" +#include "common/oai_version.h" #include "nas_user.h" #include "common/ran_context.h" @@ -134,7 +135,7 @@ void *nas_ue_task(void *args_p) user->at_response = calloc_or_fail(1, sizeof(at_response_t)); user->lowerlayer_data = calloc_or_fail(1, sizeof(lowerlayer_data_t)); /* Initialize NAS user */ - nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); + nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, OAI_FIRMWARE_VERSION); } } else @@ -174,7 +175,7 @@ void *nas_ue_task(void *args_p) user->at_response = calloc_or_fail(1, sizeof(at_response_t)); user->lowerlayer_data = calloc_or_fail(1, sizeof(lowerlayer_data_t)); /* Initialize NAS user */ - nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); + nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, OAI_FIRMWARE_VERSION); user->ueid = 0; }