From 70d10bd0374e5f9aba5cf1c300a17b3169dbce8d Mon Sep 17 00:00:00 2001 From: Tim Quatmann Date: Wed, 3 Jun 2020 10:13:39 +0200 Subject: [PATCH] Moved generated file `storm-version.cpp` to build folder. Moved version information to new library `storm-version-info` (addressing Github issue #78) --- CMakeLists.txt | 8 -- src/CMakeLists.txt | 1 + src/storm-cli-utilities/CMakeLists.txt | 6 +- src/storm-cli-utilities/cli.cpp | 8 +- src/storm-cli-utilities/model-handling.h | 1 - src/storm-version-info/CMakeLists.txt | 47 +++++++++ src/storm-version-info/storm-version.cpp.in | 24 +++++ src/storm-version-info/storm-version.h | 98 +++++++++++++++++++ src/storm/utility/storm-version.h | 100 -------------------- storm-version.cpp.in | 26 ----- 10 files changed, 177 insertions(+), 142 deletions(-) create mode 100644 src/storm-version-info/CMakeLists.txt create mode 100644 src/storm-version-info/storm-version.cpp.in create mode 100644 src/storm-version-info/storm-version.h delete mode 100644 src/storm/utility/storm-version.h delete mode 100644 storm-version.cpp.in diff --git a/CMakeLists.txt b/CMakeLists.txt index a522e67ff..4a3294ad4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -488,14 +488,6 @@ configure_file ( "${PROJECT_BINARY_DIR}/include/storm-config.h" ) -# Configure a source file to pass the Storm version to the source code -configure_file ( - "${PROJECT_SOURCE_DIR}/storm-version.cpp.in" - "${PROJECT_SOURCE_DIR}/src/storm/utility/storm-version.cpp" -) - -set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/storm/utility/storm-version.cpp") - # Add the binary dir include directory for storm-config.h include_directories("${PROJECT_BINARY_DIR}/include") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70fad6710..24a213e76 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ add_custom_target(binaries) add_subdirectory(storm) add_subdirectory(storm-counterexamples) add_subdirectory(storm-parsers) +add_subdirectory(storm-version-info) add_subdirectory(storm-cli-utilities) add_subdirectory(storm-pgcl) add_subdirectory(storm-pgcl-cli) diff --git a/src/storm-cli-utilities/CMakeLists.txt b/src/storm-cli-utilities/CMakeLists.txt index de4c0fde1..bf98385bf 100644 --- a/src/storm-cli-utilities/CMakeLists.txt +++ b/src/storm-cli-utilities/CMakeLists.txt @@ -8,7 +8,7 @@ file(GLOB_RECURSE STORM_CLI_UTIL_SOURCES ${PROJECT_SOURCE_DIR}/src/storm-cli-uti file(GLOB_RECURSE STORM_CLI_UTIL_HEADERS ${PROJECT_SOURCE_DIR}/src/storm-cli-utilities/*.h) -# Create storm-pars. +# Create storm-cli-utilities. add_library(storm-cli-utilities SHARED ${STORM_CLI_UTIL_SOURCES} ${STORM_CLI_UTIL_HEADERS}) # Remove define symbol for shared libstorm. @@ -17,7 +17,7 @@ set_target_properties(storm-cli-utilities PROPERTIES DEFINE_SYMBOL "") list(APPEND STORM_TARGETS storm-cli-utilities) set(STORM_TARGETS ${STORM_TARGETS} PARENT_SCOPE) -target_link_libraries(storm-cli-utilities PUBLIC storm storm-counterexamples storm-parsers) +target_link_libraries(storm-cli-utilities PUBLIC storm storm-counterexamples storm-parsers storm-version-info) # Install storm headers to include directory. foreach(HEADER ${STORM_CLI_UTIL_HEADERS}) @@ -33,7 +33,7 @@ foreach(HEADER ${STORM_CLI_UTIL_HEADERS}) list(APPEND STORM_CLI_UTIL_OUTPUT_HEADERS "${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}") endforeach() add_custom_target(copy_storm_cli_util_headers DEPENDS ${STORM_CLI_UTIL_OUTPUT_HEADERS} ${STORM_CLI_UTIL_HEADERS}) -add_dependencies(storm-cli-utilities copy_storm_pars_headers) +add_dependencies(storm-cli-utilities copy_storm_cli_util_headers) # installation install(TARGETS storm-cli-utilities EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL) diff --git a/src/storm-cli-utilities/cli.cpp b/src/storm-cli-utilities/cli.cpp index 9105bc9a2..4d7c891b0 100644 --- a/src/storm-cli-utilities/cli.cpp +++ b/src/storm-cli-utilities/cli.cpp @@ -3,7 +3,7 @@ #include "storm/utility/resources.h" #include "storm/utility/file.h" -#include "storm/utility/storm-version.h" +#include "storm-version-info/storm-version.h" #include "storm/utility/macros.h" #include "storm/utility/initialize.h" #include "storm/utility/SignalHandler.h" @@ -88,7 +88,7 @@ namespace storm { } void printHeader(std::string const& name, const int argc, const char** argv) { - STORM_PRINT(name << " " << storm::utility::StormVersion::shortVersionString() << std::endl << std::endl); + STORM_PRINT(name << " " << storm::StormVersion::shortVersionString() << std::endl << std::endl); // "Compute" the command line argument string with which storm was invoked. std::stringstream commandStream; @@ -107,8 +107,8 @@ namespace storm { } void printVersion(std::string const& name) { - STORM_PRINT(storm::utility::StormVersion::longVersionString() << std::endl); - STORM_PRINT(storm::utility::StormVersion::buildInfo() << std::endl); + STORM_PRINT(storm::StormVersion::longVersionString() << std::endl); + STORM_PRINT(storm::StormVersion::buildInfo() << std::endl); #ifdef STORM_HAVE_INTELTBB STORM_PRINT("Linked with Intel Threading Building Blocks v" << TBB_VERSION_MAJOR << "." << TBB_VERSION_MINOR << " (Interface version " << TBB_INTERFACE_VERSION << ")." << std::endl); diff --git a/src/storm-cli-utilities/model-handling.h b/src/storm-cli-utilities/model-handling.h index 49ce12dec..e25fd53cd 100644 --- a/src/storm-cli-utilities/model-handling.h +++ b/src/storm-cli-utilities/model-handling.h @@ -7,7 +7,6 @@ #include "storm/utility/SignalHandler.h" #include "storm/utility/file.h" -#include "storm/utility/storm-version.h" #include "storm/utility/macros.h" #include "storm/utility/NumberTraits.h" #include "storm/utility/Engine.h" diff --git a/src/storm-version-info/CMakeLists.txt b/src/storm-version-info/CMakeLists.txt new file mode 100644 index 000000000..ab3b8a85d --- /dev/null +++ b/src/storm-version-info/CMakeLists.txt @@ -0,0 +1,47 @@ + +file(GLOB_RECURSE ALL_FILES ${PROJECT_SOURCE_DIR}/src/storm-version-info/*.h ${PROJECT_SOURCE_DIR}/src/storm-version-info/*.cpp) +register_source_groups_from_filestructure("${ALL_FILES}" storm-version-info) + +file(GLOB_RECURSE STORM_VERSION_INFO_SOURCES ${PROJECT_SOURCE_DIR}/src/storm-version-info/*.cpp) +file(GLOB_RECURSE STORM_VERSION_INFO_HEADERS ${PROJECT_SOURCE_DIR}/src/storm-version-info/*.h) + +# Configure a source file to pass the Storm version to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/src/storm-version-info/storm-version.cpp.in" + "${PROJECT_BINARY_DIR}/storm-version.cpp" +) + +# Add the generated source file +list(APPEND STORM_VERSION_INFO_SOURCES "${PROJECT_BINARY_DIR}/storm-version.cpp") + + +# Create storm-version-info lib +add_library(storm-version-info SHARED ${STORM_VERSION_INFO_SOURCES} ${STORM_VERSION_INFO_HEADERS}) + +# Remove define symbol for shared libstorm. +set_target_properties(storm-version-info PROPERTIES DEFINE_SYMBOL "") + +# Add dependency to core storm libary. We are not going to link against it to avoid unnecessary linking steps, but we still want to build storm-version-info as often as possible. +add_dependencies(storm storm-version-info) +list(APPEND STORM_TARGETS storm-version-info) +set(STORM_TARGETS ${STORM_TARGETS} PARENT_SCOPE) + +# Install storm headers to include directory. +foreach(HEADER ${STORM_VERSION_INFO_HEADERS}) + string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER}) + string(REGEX MATCH "(.*)[/\\]" RELATIVE_DIRECTORY ${RELATIVE_HEADER_PATH}) + string(REGEX REPLACE "${RELATIVE_DIRECTORY}/?" "" HEADER_FILENAME ${RELATIVE_HEADER_PATH}) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME} + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY} + COMMAND ${CMAKE_COMMAND} -E copy ${HEADER} ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME} + DEPENDS ${HEADER} + ) + list(APPEND STORM_VERSION_INFO_OUTPUT_HEADERS "${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}") +endforeach() +add_custom_target(copy_storm_version_info_headers DEPENDS ${STORM_VERSION_INFO_OUTPUT_HEADERS} ${STORM_VERSION_INFO_HEADERS}) +add_dependencies(storm-version-info copy_storm_version_info_headers) + +# installation +install(TARGETS storm-version-info EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL) + diff --git a/src/storm-version-info/storm-version.cpp.in b/src/storm-version-info/storm-version.cpp.in new file mode 100644 index 000000000..dea052831 --- /dev/null +++ b/src/storm-version-info/storm-version.cpp.in @@ -0,0 +1,24 @@ +// AUTO GENERATED -- DO NOT CHANGE +#include "storm-version-info/storm-version.h" + +namespace storm { + + const unsigned StormVersion::versionMajor = @STORM_VERSION_MAJOR@; + const unsigned StormVersion::versionMinor = @STORM_VERSION_MINOR@; + const unsigned StormVersion::versionPatch = @STORM_VERSION_DEV_PATCH@; + const std::string StormVersion::versionLabel = "@STORM_VERSION_LABEL@"; + 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 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@"; + const std::string StormVersion::cxxCompiler = "@STORM_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"; +#ifdef NDEBUG + const std::string StormVersion::cxxFlags = "@CMAKE_CXX_FLAGS@" " " "@CMAKE_CXX_FLAGS_RELEASE@"; +#else + const std::string StormVersion::cxxFlags = "@CMAKE_CXX_FLAGS@" " " "@CMAKE_CXX_FLAGS_DEBUG@"; +#endif + +} diff --git a/src/storm-version-info/storm-version.h b/src/storm-version-info/storm-version.h new file mode 100644 index 000000000..297361fbb --- /dev/null +++ b/src/storm-version-info/storm-version.h @@ -0,0 +1,98 @@ +#pragma once + +#include +#include + +#include + +namespace storm { + + struct StormVersion { + /// The major version of Storm. + const static unsigned versionMajor; + + /// The minor version of Storm. + const static unsigned versionMinor; + + /// The patch version of Storm. + const static unsigned versionPatch; + + /// The label version of Storm (might be empty). + const static std::string versionLabel; + + /// Flag indicating if the version of Storm is a development version. + const static bool versionDev; + + enum class VersionSource { + Git, Static + }; + + /// 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 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; + + /// The system which has compiled Storm. + const static std::string systemName; + + /// The system version which has compiled Storm. + const static std::string systemVersion; + + /// The compiler version that was used to build Storm. + const static std::string cxxCompiler; + + /// The flags that were used to build Storm. + const static std::string cxxFlags; + + static std::string shortVersionString() { + std::stringstream sstream; + sstream << versionMajor << "." << versionMinor << "." << versionPatch; + if (!versionLabel.empty()) { + sstream << "-" << versionLabel; + } + if (versionDev) { + sstream << " (dev)"; + } + return sstream.str(); + } + + static std::string longVersionString() { + std::stringstream sstream; + sstream << "Version " << shortVersionString(); + if (versionSource == VersionSource::Static) { + sstream << " (derived statically)"; + } + if (commitsAhead > 0) { + sstream << " (+ " << commitsAhead << " commits)"; + } + if (!gitRevisionHash.empty()) { + sstream << " build from revision " << gitRevisionHash; + } else { + sstream << " built from archive"; + } + if (dirty) { + if (dirty.get()) { + sstream << " (dirty)"; + } else { + sstream << " (clean)"; + } + } else { + sstream << " (potentially dirty)"; + } + return sstream.str(); + } + + static std::string buildInfo() { + std::stringstream sstream; + sstream << "Compiled on " << systemName << " " << systemVersion << " using " << cxxCompiler << " with flags '" << cxxFlags << "'"; + return sstream.str(); + } + }; +} diff --git a/src/storm/utility/storm-version.h b/src/storm/utility/storm-version.h deleted file mode 100644 index e87cbd489..000000000 --- a/src/storm/utility/storm-version.h +++ /dev/null @@ -1,100 +0,0 @@ -#pragma once - -#include -#include - -#include - -namespace storm { - namespace utility { - - struct StormVersion { - /// The major version of Storm. - const static unsigned versionMajor; - - /// The minor version of Storm. - const static unsigned versionMinor; - - /// The patch version of Storm. - const static unsigned versionPatch; - - /// The label version of Storm (might be empty). - const static std::string versionLabel; - - /// Flag indicating if the version of Storm is a development version. - const static bool versionDev; - - enum class VersionSource { - Git, Static - }; - - /// 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 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; - - /// The system which has compiled Storm. - const static std::string systemName; - - /// The system version which has compiled Storm. - const static std::string systemVersion; - - /// The compiler version that was used to build Storm. - const static std::string cxxCompiler; - - /// The flags that were used to build Storm. - const static std::string cxxFlags; - - static std::string shortVersionString() { - std::stringstream sstream; - sstream << versionMajor << "." << versionMinor << "." << versionPatch; - if (!versionLabel.empty()) { - sstream << "-" << versionLabel; - } - if (versionDev) { - sstream << " (dev)"; - } - return sstream.str(); - } - - static std::string longVersionString() { - std::stringstream sstream; - sstream << "Version " << shortVersionString(); - if (versionSource == VersionSource::Static) { - sstream << " (derived statically)"; - } - if (commitsAhead > 0) { - sstream << " (+ " << commitsAhead << " commits)"; - } - if (!gitRevisionHash.empty()) { - sstream << " build from revision " << gitRevisionHash; - } else { - sstream << " built from archive"; - } - if (dirty) { - if (dirty.get()) { - sstream << " (dirty)"; - } else { - sstream << " (clean)"; - } - } else { - sstream << " (potentially dirty)"; - } - return sstream.str(); - } - - static std::string buildInfo() { - std::stringstream sstream; - sstream << "Compiled on " << systemName << " " << systemVersion << " using " << cxxCompiler << " with flags '" << cxxFlags << "'"; - return sstream.str(); - } - }; - } -} diff --git a/storm-version.cpp.in b/storm-version.cpp.in deleted file mode 100644 index f74b2cbc7..000000000 --- a/storm-version.cpp.in +++ /dev/null @@ -1,26 +0,0 @@ -// AUTO GENERATED -- DO NOT CHANGE -#include "storm/utility/storm-version.h" - -namespace storm { - namespace utility { - - const unsigned StormVersion::versionMajor = @STORM_VERSION_MAJOR@; - const unsigned StormVersion::versionMinor = @STORM_VERSION_MINOR@; - const unsigned StormVersion::versionPatch = @STORM_VERSION_DEV_PATCH@; - const std::string StormVersion::versionLabel = "@STORM_VERSION_LABEL@"; - 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 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@"; - const std::string StormVersion::cxxCompiler = "@STORM_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"; -#ifdef NDEBUG - const std::string StormVersion::cxxFlags = "@CMAKE_CXX_FLAGS@" " " "@CMAKE_CXX_FLAGS_RELEASE@"; -#else - const std::string StormVersion::cxxFlags = "@CMAKE_CXX_FLAGS@" " " "@CMAKE_CXX_FLAGS_DEBUG@"; -#endif - - } -}