build: move build_version.py to tools/, so any env can stamp its version

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-08-04 10:59:48 +02:00
1 parent c6467a2451
commit d3f27cd844
2 files changed
+2 -2

No files matched your search

-25
View File
@@ -1,25 +0,0 @@
# 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))
+2 -2
View File
@@ -57,9 +57,9 @@ build_src_filter = ${SenseCap_Solar.build_src_filter}
extends = SenseCap_Solar
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
board_upload.maximum_size = 708608
; custom version + build timestamp for `ver` (see build_version.py)
; custom version + build timestamp for `ver` (see tools/build_version.py)
extra_scripts = ${nrf52_base.extra_scripts}
pre:variants/sensecap_solar/build_version.py
pre:tools/build_version.py
build_flags =
${SenseCap_Solar.build_flags}
-D ADVERT_NAME='"SenseCap_Solar Repeater"'