build: move build_version.py to tools/, so any env can stamp its version
The script has nothing SenseCap-specific in it -- it reads the git SHA and
the clock -- but it sat under variants/sensecap_solar/ and only that
variant referenced it. Everything else silently shipped the hardcoded
literals from examples/*/MyMesh.h ("v1.16.0", "6 Jun 2026"), identical in
every build.
That cost real time tonight. After a 14-minute BLE DFU onto the T1000-E
tracker, every field the node reports back -- ver, fw_build, model,
max_contacts -- was byte-for-byte what it had said before the flash, so
`ver` could not distinguish the new image from the old one. The only
evidence the image had actually landed was the bootloader's own IMAGE ok /
VALIDATE ok. That is sound evidence, but it lives in a log that scrolls
away, not on the device you can query a month later.
Verified after the move: SenseCap_Solar_repeater_ble, SenseCap_ples_rpt and
T1000E_cmp_cz all stamp v1.16.0-tth-<sha> and a build timestamp.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5333a71927
commit
4759954c58
2 files changed
+2
-2
No files matched your search
@@ -0,0 +1,25 @@
|
||||
# CUSTOM (TeTeHacko): custom version and build date/time for the `ver` command.
|
||||
# Injects FIRMWARE_VERSION (v1.16.0-tth-<git sha>, '+' = dirty tree) and
|
||||
# FIRMWARE_BUILD_DATE (compile time). NOTE: the define changes every build =
|
||||
# full rebuild each time (~10-30 s) -- the price for an always-fresh timestamp.
|
||||
Import("env")
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
sha = "nogit"
|
||||
dirty = ""
|
||||
try:
|
||||
cwd = env.subst("$PROJECT_DIR")
|
||||
sha = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=cwd).decode().strip()
|
||||
if subprocess.call(["git", "diff", "--quiet"], cwd=cwd) != 0:
|
||||
dirty = "+"
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
version = "v1.16.0-tth-%s%s" % (sha, dirty)
|
||||
build_date = datetime.now().strftime("%d %b %Y %H:%M")
|
||||
env.Append(CPPDEFINES=[
|
||||
("FIRMWARE_VERSION", env.StringifyMacro(version)),
|
||||
("FIRMWARE_BUILD_DATE", env.StringifyMacro(build_date)),
|
||||
])
|
||||
print("build_version.py: %s (Build: %s)" % (version, build_date))
|
||||
Reference in new issue
Block a user