You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.2 KiB

  1. #pragma once
  2. #include <string>
  3. #include <sstream>
  4. namespace storm {
  5. struct StormVersion {
  6. /// The major version of Storm.
  7. const static unsigned versionMajor;
  8. /// The minor version of Storm.
  9. const static unsigned versionMinor;
  10. /// The patch version of Storm.
  11. const static unsigned versionPatch;
  12. /// The label version of Storm (might be empty).
  13. const static std::string versionLabel;
  14. /// Flag indicating if the version of Storm is a development version.
  15. const static bool versionDev;
  16. enum class VersionSource {
  17. Git, Static
  18. };
  19. /// The source of the versioning information.
  20. const static VersionSource versionSource;
  21. /// The short hash of the git commit this build is based on
  22. const static std::string gitRevisionHash;
  23. /// How many commits passed since the tag was last set.
  24. const static unsigned commitsAhead;
  25. enum class DirtyState {
  26. Clean, /// no files were modified in the checkout
  27. Dirty, /// some files were modified
  28. Unknown /// No information about dirtyness is given.
  29. };
  30. /// Indicates whether files were modified
  31. const static DirtyState dirty;
  32. /// The system which has compiled Storm.
  33. const static std::string systemName;
  34. /// The system version which has compiled Storm.
  35. const static std::string systemVersion;
  36. /// The compiler version that was used to build Storm.
  37. const static std::string cxxCompiler;
  38. /// The flags that were used to build Storm.
  39. const static std::string cxxFlags;
  40. static std::string shortVersionString() {
  41. std::stringstream sstream;
  42. sstream << versionMajor << "." << versionMinor << "." << versionPatch;
  43. if (!versionLabel.empty()) {
  44. sstream << "-" << versionLabel;
  45. }
  46. if (versionDev) {
  47. sstream << " (dev)";
  48. }
  49. return sstream.str();
  50. }
  51. static std::string longVersionString() {
  52. std::stringstream sstream;
  53. sstream << "Version " << shortVersionString();
  54. if (versionSource == VersionSource::Static) {
  55. sstream << " (derived statically)";
  56. }
  57. if (commitsAhead > 0) {
  58. sstream << " (+ " << commitsAhead << " commits)";
  59. }
  60. if (!gitRevisionHash.empty()) {
  61. sstream << " build from revision " << gitRevisionHash;
  62. } else {
  63. sstream << " built from archive";
  64. }
  65. switch (dirty) {
  66. case DirtyState::Clean: sstream << " (clean)"; break;
  67. case DirtyState::Dirty: sstream << " (dirty)"; break;
  68. default: sstream << " (potentially dirty)"; break;
  69. }
  70. return sstream.str();
  71. }
  72. static std::string buildInfo() {
  73. std::stringstream sstream;
  74. sstream << "Compiled on " << systemName << " " << systemVersion << " using " << cxxCompiler << " with flags '" << cxxFlags << "'";
  75. return sstream.str();
  76. }
  77. };
  78. }