Distributed test zips go stale and stray. BT_EXPIRE (CMake option,
DEFAULT ON so a zip can never accidentally ship without it) makes the
exe refuse to start BT_EXPIRE_DAYS (default 14) after its build day:
boot logs the remaining window, an expired build logs + shows a
"test build expired -- ask the operator for the current build" box and
exits. btversion.h now stamps BT_BUILD_UNIX (UTC-midnight-rounded so
the only-on-change header churns once per day, not every build) +
BT_BUILD_DATE. Dev is unaffected: every build re-stamps the day.
-DBT_EXPIRE=OFF builds a non-expiring exe; mkdist reads the cache and
marks such a zip "-noexpire" + prints a warning, and the tester README
expiry note is {EXPIRE}-marker-gated like the steam lines. Second
compile-gate exception after BT_STEAM (convention updated in
glass-cockpit.md). Quality gate, not DRM -- a clock rollback defeats it.
Verified live: default build logs "test build window: 14 day(s) left";
a -DBT_EXPIRE_DAYS=0 build logs TEST BUILD EXPIRED and parks on the
explanation box (window title checked) without starting the game;
restored to 14 and rebuilt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
2.5 KiB
CMake
67 lines
2.5 KiB
CMake
# btversion.cmake -- generate btversion.h from git at BUILD time.
|
|
#
|
|
# Version scheme (2026-07-18): the arcade release is 4.10; the win32
|
|
# reconstruction is 4.11; the BUILD number is the git commit count --
|
|
# monotonic, zero-maintenance, and any build pins to exact source via the
|
|
# hash. A '+' suffix marks an uncommitted working tree.
|
|
#
|
|
# Invoked: cmake -DOUT=<header> -DSRC=<repo root> -P btversion.cmake
|
|
|
|
# Build DAY stamp (UTC midnight epoch) for the tester-build expiry tripwire
|
|
# (BT_EXPIRE). Day precision on purpose: the header is written only-on-change,
|
|
# so a per-second stamp would churn btl4main.obj on every no-op build.
|
|
string(TIMESTAMP BT_NOW_UNIX "%s" UTC)
|
|
math(EXPR BT_BUILD_UNIX "(${BT_NOW_UNIX} / 86400) * 86400")
|
|
string(TIMESTAMP BT_BUILD_DATE "%Y-%m-%d" UTC)
|
|
|
|
execute_process(COMMAND git rev-list --count HEAD
|
|
WORKING_DIRECTORY "${SRC}"
|
|
OUTPUT_VARIABLE BT_BUILD OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
ERROR_QUIET)
|
|
execute_process(COMMAND git rev-parse --short HEAD
|
|
WORKING_DIRECTORY "${SRC}"
|
|
OUTPUT_VARIABLE BT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
ERROR_QUIET)
|
|
# content/LAST.EGG is rewritten by the game every run and content/OPERATOR.EGG
|
|
# is overwritten by the operator app on Save -- both are runtime working files,
|
|
# not source, so exclude them (else the build stamps a false '+' dirty marker).
|
|
execute_process(COMMAND git status --porcelain --untracked-files=no
|
|
-- . ":(exclude)content/LAST.EGG"
|
|
":(exclude)content/OPERATOR.EGG"
|
|
WORKING_DIRECTORY "${SRC}"
|
|
OUTPUT_VARIABLE BT_DIRTY_RAW
|
|
ERROR_QUIET)
|
|
|
|
if(NOT BT_BUILD)
|
|
set(BT_BUILD 0)
|
|
endif()
|
|
if(NOT BT_HASH)
|
|
set(BT_HASH "nogit")
|
|
endif()
|
|
if(BT_DIRTY_RAW STREQUAL "")
|
|
set(BT_DIRTY "")
|
|
else()
|
|
set(BT_DIRTY "+")
|
|
endif()
|
|
|
|
set(CONTENT "// generated by tools/btversion.cmake -- do not edit, not in git
|
|
#define BT_VERSION_MAJOR 4
|
|
#define BT_VERSION_MINOR 11
|
|
#define BT_VERSION_BUILD ${BT_BUILD}
|
|
#define BT_VERSION_STRING \"4.11.${BT_BUILD}\"
|
|
#define BT_VERSION_HASH \"${BT_HASH}${BT_DIRTY}\"
|
|
#define BT_VERSION_FULL \"4.11.${BT_BUILD} (${BT_HASH}${BT_DIRTY})\"
|
|
#define BT_BUILD_UNIX ${BT_BUILD_UNIX}
|
|
#define BT_BUILD_DATE \"${BT_BUILD_DATE}\"
|
|
")
|
|
|
|
# write only when changed so incremental builds don't churn
|
|
if(EXISTS "${OUT}")
|
|
file(READ "${OUT}" OLD)
|
|
else()
|
|
set(OLD "")
|
|
endif()
|
|
if(NOT OLD STREQUAL CONTENT)
|
|
file(WRITE "${OUT}" "${CONTENT}")
|
|
endif()
|