Bladeren bron

release(v2.4.1): --version reports the real version

printVersion() had a hardcoded "1.0.0" literal at main.cpp:113, so the
server binary misreported its version for the entire 2.x line. The one
command an operator reaches for during triage was the least trustworthy.

Wire SMARTBOTIC_DB_VERSION_STRING into the service target from the
top-level VERSION file, which CMakeLists.txt already reads at line 7 but
never passed down. The #ifndef fallback is "unknown" rather than another
literal: an honest "unknown" is debuggable, a stale version is not.

Verified by bumping VERSION 2.4.0 -> 2.4.1 and rebuilding: --version
followed with no code edit. ctest 14/14 green.
fszontagh 1 maand geleden
bovenliggende
commit
b2a18b290e
3 gewijzigde bestanden met toevoegingen van 15 en 2 verwijderingen
  1. 1 1
      VERSION
  2. 6 0
      service/CMakeLists.txt
  3. 8 1
      service/src/main.cpp

+ 1 - 1
VERSION

@@ -1 +1 @@
-2.4.0
+2.4.1

+ 6 - 0
service/CMakeLists.txt

@@ -76,6 +76,12 @@ target_include_directories(smartbotic-database PRIVATE
     ${CMAKE_CURRENT_SOURCE_DIR}/src
 )
 
+# Version string comes from the top-level VERSION file so --version can never
+# drift from the deb version again (it reported a hardcoded 1.0.0 for all of 2.x).
+target_compile_definitions(smartbotic-database PRIVATE
+    SMARTBOTIC_DB_VERSION_STRING="${SMARTBOTIC_DB_VERSION}"
+)
+
 # Link dependencies
 if(BUILD_SHARED_LIBS)
     target_link_libraries(smartbotic-database PRIVATE smartbotic-db-client)

+ 8 - 1
service/src/main.cpp

@@ -109,8 +109,15 @@ void printUsage(const char* programName) {
               << std::endl;
 }
 
+// Injected by service/CMakeLists.txt from the top-level VERSION file. The
+// fallback reports "unknown" rather than a plausible-looking literal: an
+// honest "unknown" is debuggable, a stale version string is not.
+#ifndef SMARTBOTIC_DB_VERSION_STRING
+#define SMARTBOTIC_DB_VERSION_STRING "unknown"
+#endif
+
 void printVersion() {
-    std::cout << "smartbotic-database version 1.0.0\n"
+    std::cout << "smartbotic-database version " << SMARTBOTIC_DB_VERSION_STRING << "\n"
               << "Smartbotic Database Service\n"
               << std::endl;
 }