From 41b27f262791126322dec64eaf3a1c4f576778c5 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 4 Nov 2013 18:26:50 +0100 Subject: [PATCH] Define SIMGRID_VERSION_STRING, and add option --version to get version information at run time. --- CMakeLists.txt | 8 +++++++- ChangeLog | 3 +++ buildtools/Cmake/CompleteInFiles.cmake | 14 +++++++++++--- buildtools/Cmake/PrintArgs.cmake | 4 ++-- include/simgrid_config.h.in | 2 ++ src/simgrid/sg_config.c | 5 +++++ 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6adbbd2a62..e124fa9af8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,19 +45,25 @@ set(CMAKE_Fortran_LINK_FLAGS "" CACHE TYPE INTERNAL FORCE) # 3.7.{0,1} -> release 3.7, 3.7.1 # 3.8.{0,1} -> release 3.8, 3.8.1 # 3.9.0 -> release 3.9 - # 3.9.90 -> release 3.10pre1 # 3.10.0 -> release 3.10 set(SIMGRID_VERSION_MAJOR "3") set(SIMGRID_VERSION_MINOR "9") set(SIMGRID_VERSION_PATCH "90") +set(SIMGRID_VERSION_EXTRA "") # Extra words to add to version string (e.g. -rc1) + +set(SIMGRID_VERSION_DATE "2013") # Year for copyright information if(${SIMGRID_VERSION_PATCH} EQUAL "0") set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}") else() set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}.${SIMGRID_VERSION_PATCH}") endif() + +set(SIMGRID_VERSION_STRING + "SimGrid version ${release_version}${SIMGRID_VERSION_EXTRA}\\nCopyright (c) ${SIMGRID_VERSION_DATE}. The Simgrid Team.") + set(libsimgrid_version "${release_version}") set(libsimgrid-java_version "${release_version}") set(GCC_NEED_VERSION "4.0") diff --git a/ChangeLog b/ChangeLog index b63150632c..854568de47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -76,6 +76,9 @@ SimGrid (3.10pre1) unstable; urgency=low Unfortunately, calling exit may cause SimGrid to segfault, which is quite annoying when scripting around the simulator. Adding a --cfg=clean_atexit:no allows to circumvent this issue. + * New command line option --version, to get SimGrid version information. + Packagers may want to add extra words to SIMGRID_VERSION_EXTRA defined in + CMakeLists.txt. -- Mon Oct 7 2013 Da SimGrid team diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index 846f9ea617..eaf6c294ee 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -511,12 +511,20 @@ if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/ AND NOT WIN32) string(REPLACE "\n" "" GIT_DATE "${GIT_DATE}") message(STATUS "Git date: ${GIT_DATE}") string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}") - STRING(REPLACE " +0000" "" GIT_DATE "${GIT_DATE}") - STRING(REPLACE " " "~" GIT_DATE "${GIT_DATE}") - STRING(REPLACE ":" "-" GIT_DATE "${GIT_DATE}") endif() endif() +if(release) + set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING}\\nRelease build") +else() + set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING}\\nDevelopment build") +endif() +if(GIT_VERSION) + set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING} at commit ${GIT_VERSION}") +endif() +if(GIT_DATE) + set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING} (${GIT_DATE})") +endif() #-------------------------------------------------------------------------------------------------- set(makecontext_CPPFLAGS_2 "") diff --git a/buildtools/Cmake/PrintArgs.cmake b/buildtools/Cmake/PrintArgs.cmake index d15127a6f1..200f671745 100644 --- a/buildtools/Cmake/PrintArgs.cmake +++ b/buildtools/Cmake/PrintArgs.cmake @@ -74,9 +74,9 @@ message("\nConfiguration of package `simgrid':") message(" BUILDNAME ...........: ${BUILDNAME}") message(" SITE ................: ${SITE}") if(release) - message(" Release .............: simgrid-${release_version} (release build)") + message(" Release .............: simgrid-${release_version}${SIMGRID_VERSION_EXTRA} (release build)") else() - message(" Release .............: simgrid-${release_version} (development build)") + message(" Release .............: simgrid-${release_version}${SIMGRID_VERSION_EXTRA} (development build)") endif() message("") message(" Compiler: C .........: ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID})") diff --git a/include/simgrid_config.h.in b/include/simgrid_config.h.in index fb08c2903a..789464f23e 100644 --- a/include/simgrid_config.h.in +++ b/include/simgrid_config.h.in @@ -22,6 +22,8 @@ SG_BEGIN_DECL() #define SIMGRID_VERSION_MINOR @SIMGRID_VERSION_MINOR@ #define SIMGRID_VERSION_PATCH @SIMGRID_VERSION_PATCH@ +#define SIMGRID_VERSION_STRING "@SIMGRID_VERSION_STRING@" + /* Version X.Y.Z will get version number XYZ: all digits concatenated without dots * (with Y and Z must be on two positions)*/ diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 0f88330755..b812c87d55 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -55,6 +55,9 @@ static void sg_config_cmd_line(int *argc, char **argv) xbt_cfg_set_parse(_sg_cfg_set, opt); XBT_DEBUG("Did apply '%s' as config setting", opt); + } else if (!strcmp(argv[i], "--version")) { + printf("%s\n", SIMGRID_VERSION_STRING); + shall_exit = 1; } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) { printf ("Description of the configuration accepted by this simulator:\n"); @@ -71,6 +74,8 @@ static void sg_config_cmd_line(int *argc, char **argv) #endif "\n" "You can also use --help-logs and --help-log-categories to see the details of logging output.\n" +"\n" +"You can also use --version to get SimGrid version information.\n" "\n" ); shall_exit = 1; -- 2.20.1