Change build date to commit date in version string

Use build date only when there is no commit.
This commit is contained in:
bob committed 2026-10-30 12:48:51 +01:00
1 parent b9a2cd51f6
commit 62a89679f0
2 files changed
+12 -10

No files matched your search

+2 -1
View File
@@ -2,7 +2,8 @@ include premake.make
# git commit hash and version for this build # git commit hash and version for this build
COMMIT-HASH != git log 2>/dev/null | sed -e '1s/^commit //;q' COMMIT-HASH != git log 2>/dev/null | sed -e '1s/^commit //;q'
COMMIT := "static const char* commit = \"$(COMMIT-HASH)\";" COMMITDATE != git log 2>/dev/null | sed -ne '3p' | sed -e 's/^Date: //'
COMMIT := "const char* commit = \"$(COMMIT-HASH), $(COMMITDATE)\";"
VERSION := "static const char* version = \"$(MAJOR).$(MINOR).$(PATCH)\";" VERSION := "static const char* version = \"$(MAJOR).$(MINOR).$(PATCH)\";"
# some important install locations # some important install locations
+10 -9
View File
@@ -4,16 +4,17 @@
std::string {PROJECT}_version() { std::string {PROJECT}_version() {
#include "version.inc" #include "version.inc"
#include "commit.inc" #include "commit.inc"
std::ostringstream oss; std::ostringstream oss;
oss << "{PROJECT} version " << version; oss << "{PROJECT} version " << version;
#ifdef DEBUG #ifdef DEBUG
oss << " DEBUG"; oss << " DEBUG";
#endif #endif
oss << '\n'; oss << '\n';
if (commit[0] != '\0') { if (commit[0] != '\0') {
oss << "build " << commit << ", "; oss << "build " << commit << '\n';
} } else {
oss << __DATE__ << ", " << __TIME__ << '\n'; oss << __DATE__ << ", " << __TIME__ << '\n';
oss << "(c) Bob Polis, all rights reserved"; }
return oss.str(); oss << "(c) Bob Polis, all rights reserved";
return oss.str();
} }