From 9902bb9dff49052ecd04817f31c9ade4cc948273 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Tue, 17 Jul 2018 14:22:21 +0200 Subject: [PATCH] Fixed version parsing for 'commits ahead' --- CMakeLists.txt | 34 +++++++++++++++---------------- src/storm/utility/storm-version.h | 8 ++++---- storm-version.cpp.in | 2 +- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee6c1117c..2dec13d80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -420,16 +420,22 @@ set(STORM_VERSION_MAJOR "${CMAKE_MATCH_1}") set(STORM_VERSION_MINOR "${CMAKE_MATCH_2}") set(STORM_VERSION_PATCH "${CMAKE_MATCH_3}") set(STORM_GIT_VERSION_REST "${CMAKE_MATCH_4}") -# parse rest of the form (-label)-commitsahead-hash-appendix +# parse rest of the form (-label)-commitsahead-hash(-appendix) string(REGEX MATCH "^(\\-([a-z][a-z0-9\\.]+))?\\-([0-9]+)\\-([a-z0-9]+)(\\-.*)?$" STORM_VERSION_REST_MATCH "${STORM_GIT_VERSION_REST}") set(STORM_VERSION_LABEL "${CMAKE_MATCH_2}") # might be empty set(STORM_VERSION_COMMITS_AHEAD "${CMAKE_MATCH_3}") -set(STORM_VERSION_TAG_HASH "${CMAKE_MATCH_4}") +set(STORM_VERSION_TAG_HASH "${CMAKE_MATCH_4}") # is not used set(STORM_VERSION_APPENDIX "${CMAKE_MATCH_5}") # might be empty - -set(STORM_VERSION_DIRTY boost::none) -if (NOT "${STORM_GIT_VERSION_STRING}" STREQUAL "") +# check whether the git version lookup failed +if (STORM_GIT_VERSION_STRING MATCHES "NOTFOUND") + set(STORM_VERSION_SOURCE "VersionSource::Static") + set(STORM_VERSION_COMMITS_AHEAD 0) + set(STORM_VERSION_DIRTY boost::none) + include(version.cmake) + message(WARNING "Storm - Git version information not available, statically assuming version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}.") +else() + set(STORM_VERSION_SOURCE "VersionSource::Git") if ("${STORM_VERSION_APPENDIX}" MATCHES "^.*dirty.*$") set(STORM_VERSION_DIRTY "true") else() @@ -437,15 +443,6 @@ if (NOT "${STORM_GIT_VERSION_STRING}" STREQUAL "") endif() endif() -# now check whether the git version lookup failed -set(STORM_VERSION_SOURCE "VersionSource::Git") -if (STORM_GIT_VERSION_STRING MATCHES "NOTFOUND") - set(STORM_VERSION_SOURCE "VersionSource::Static") - set(STORM_VERSION_COMMITS_AHEAD "boost::none") - include(version.cmake) - message(WARNING "Storm - Git version information not available, statically assuming version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}.") -endif() - # check whether there is a label ('alpha', 'pre', etc.) if ("${STORM_VERSION_LABEL}" STREQUAL "") set(STORM_VERSION_LABEL_STRING "") @@ -454,18 +451,19 @@ else() endif() # check for development version with commits ahead of latest tag -set(STORM_VERSION_DEV "false") -set(STORM_VERSION_DEV_STRING "") if(STORM_VERSION_COMMITS_AHEAD) + set(STORM_VERSION_DEV "true") + set(STORM_VERSION_DEV_STRING " (dev)") if ("${STORM_VERSION_LABEL}" STREQUAL "") # increase patch number to indicate newer version MATH(EXPR STORM_VERSION_DEV_PATCH "${STORM_VERSION_PATCH}+1") else() set(STORM_VERSION_DEV_PATCH "${STORM_VERSION_PATCH}") endif() - set(STORM_VERSION_DEV "true") - set(STORM_VERSION_DEV_STRING " (dev)") else() + set(STORM_VERSION_COMMITS_AHEAD 0) + set(STORM_VERSION_DEV "false") + set(STORM_VERSION_DEV_STRING "") set(STORM_VERSION_DEV_PATCH ${STORM_VERSION_PATCH}) endif() diff --git a/src/storm/utility/storm-version.h b/src/storm/utility/storm-version.h index b6b1d3d2e..e87cbd489 100644 --- a/src/storm/utility/storm-version.h +++ b/src/storm/utility/storm-version.h @@ -30,12 +30,12 @@ namespace storm { /// The source of the versioning information. const static VersionSource versionSource; - + /// The short hash of the git commit this build is based on const static std::string gitRevisionHash; /// How many commits passed since the tag was last set. - const static boost::optional commitsAhead; + const static unsigned commitsAhead; /// 0 iff there no files were modified in the checkout, 1 otherwise. If none, no information about dirtyness is given. const static boost::optional dirty; @@ -70,8 +70,8 @@ namespace storm { if (versionSource == VersionSource::Static) { sstream << " (derived statically)"; } - if (commitsAhead) { - sstream << " (+ " << commitsAhead.get() << " commits)"; + if (commitsAhead > 0) { + sstream << " (+ " << commitsAhead << " commits)"; } if (!gitRevisionHash.empty()) { sstream << " build from revision " << gitRevisionHash; diff --git a/storm-version.cpp.in b/storm-version.cpp.in index 6e3706bae..f74b2cbc7 100644 --- a/storm-version.cpp.in +++ b/storm-version.cpp.in @@ -11,7 +11,7 @@ namespace storm { const bool StormVersion::versionDev = @STORM_VERSION_DEV@; const StormVersion::VersionSource StormVersion::versionSource = @STORM_VERSION_SOURCE@; const std::string StormVersion::gitRevisionHash = "@STORM_VERSION_GIT_HASH@"; - const boost::optional StormVersion::commitsAhead = @STORM_VERSION_COMMITS_AHEAD@; + const unsigned StormVersion::commitsAhead = @STORM_VERSION_COMMITS_AHEAD@; const boost::optional StormVersion::dirty = @STORM_VERSION_DIRTY@; const std::string StormVersion::systemName = "@CMAKE_SYSTEM_NAME@"; const std::string StormVersion::systemVersion = "@CMAKE_SYSTEM_VERSION@";