Stamp the build's identity into GameVersion.cpp from CMake

GameVersion.cpp becomes a configure_file template, so the version strings are a
build input rather than something a CI step seds into the working tree mid-run.
That is what lets a crash report be matched to its exact build's PDB for offline
symbolization.

The two strings get distinct jobs. czVersionString is the machine-readable build
identity: the bare short commit SHA and nothing else. A `git describe` string
cannot serve here -- czVersionString is 16 bytes because it is stored in the
savegame header as SAVED_GAME_HEADER::zGameVersionNumber and strcmp'd on load,
and describe puts the SHA last, so truncation ate exactly the discriminating part
and could make two different commits compare equal. CI passes 9 hex; anything
that would not fit is now a configure error rather than a silent clip.

zBuildInformation is the display string, untruncated, and it is no longer printed
beside czVersionString: that drops the duplication in the version line ("JA2 1.13
V4-555-G6A941C0 2026-07-25 V4-555-G6A941C06") and stops showing a token that is
now machine-only. CI's copy leads with GAME_VERSION, because the version line is
now the only place a player reads which release they are running.

Finish what the sed step's TODO asked for: the workflow pins GAME_BUILD_INFORMATION
and GIT_SHA once, next to the gamedir SHAs it already pins, and hands them to CMake
with -D. Every parallel build job therefore stamps one agreed identity, and the
compile checkout needs no git history at all.

A build nobody identifies is a local build and says so -- czVersionString reads
"local" -- rather than deriving a SHA from HEAD. A derived SHA could not stay
true: nothing re-runs configure once HEAD moves, so an incremental build would
keep whatever it was configured with, and keeping it honest would mean
reconfiguring on every commit. It would also buy nothing, because only packaged
builds are archived with their PDBs; a local build's crash reports are symbolized
against the PDB sitting next to the exe.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Marco Antonio J. Costa
2026-07-28 10:25:47 -03:00
committed by majcosta
co-authored by Claude Opus 5
parent 00dad8aa12
commit 1e2ce70315
7 changed files with 81 additions and 25 deletions
+8 -2
View File
@@ -13,9 +13,15 @@ extern "C" {
// name of the product, Unfinished Business, Map Editor etc..
extern CHAR16 zProductLabel[64];
// used for save game comparison
// this build's identity, stamped in by CMake from -DGIT_SHA. A packaged build sets
// it to the bare short commit SHA and nothing else, so it names that build exactly;
// a build nobody identified reads "local". Used for save game comparison, and
// stamped into crash reports so a packaged build's report can be matched to the PDB
// archived beside it for offline symbolization.
extern CHAR8 czVersionString[16];
// can contain information regarding the build: what git ref was the base (tag, branch), by whom, commit date, build date, etc..
// human-readable build description, stamped in from -DGAME_BUILD_INFORMATION: the
// release name, its date and where it was built, or "local build <date>". For
// display only — never compared against, so it is free to change shape.
extern CHAR16 zBuildInformation[256];
//ADB: I needed these here so I moved them, and why put them in *.cpp anyways?