NodeMaintenance, build_version.py: back to the original formatting
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46d33bd2b0
commit
73c1a7beb2
3 files changed
+86
-107
No files matched your search
+16
-32
@@ -25,11 +25,8 @@ from datetime import datetime
|
||||
|
||||
|
||||
def git(cwd, *args):
|
||||
return (
|
||||
subprocess.check_output(("git",) + args, cwd=cwd, stderr=subprocess.DEVNULL)
|
||||
.decode()
|
||||
.strip()
|
||||
)
|
||||
return subprocess.check_output(("git",) + args, cwd=cwd,
|
||||
stderr=subprocess.DEVNULL).decode().strip()
|
||||
|
||||
|
||||
cwd = env.subst("$PROJECT_DIR")
|
||||
@@ -47,24 +44,15 @@ cwd = env.subst("$PROJECT_DIR")
|
||||
# version string of the thing it was protecting.
|
||||
base = "nover"
|
||||
try:
|
||||
tag = git(
|
||||
cwd,
|
||||
"describe",
|
||||
"--tags",
|
||||
"--abbrev=0",
|
||||
"--match",
|
||||
"*v[0-9]*",
|
||||
"--exclude",
|
||||
"*+tth*",
|
||||
"--exclude",
|
||||
"backup/*",
|
||||
)
|
||||
tag = git(cwd, "describe", "--tags", "--abbrev=0",
|
||||
"--match", "*v[0-9]*", "--exclude", "*+tth*",
|
||||
"--exclude", "backup/*")
|
||||
# Cut at the 'v' that STARTS THE VERSION, not at the first 'v' in the tag:
|
||||
# "room-server-v1.17.0" has one in "server", and find("v") turned the base
|
||||
# into "ver-v1.17.0". Every earlier upstream tag we saw (companion-, repeater-)
|
||||
# happened to have no 'v' in its prefix, so this hid until v1.17.0.
|
||||
m = re.search(r"v[0-9]", tag)
|
||||
base = tag[m.start() :] if m else tag
|
||||
base = tag[m.start():] if m else tag
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -91,12 +79,10 @@ VER_LIMIT, DATE_LIMIT = 19, 11
|
||||
# so this only bites if upstream's version string grows unusually long.
|
||||
marker = "-tth"
|
||||
room = VER_LIMIT - len(base) - len(marker) - len(dirty)
|
||||
version = "%s%s%s%s" % (base, marker, sha[: max(4, room)], dirty)
|
||||
version = "%s%s%s%s" % (base, marker, sha[:max(4, room)], dirty)
|
||||
if len(version) > VER_LIMIT:
|
||||
print(
|
||||
"build_version.py: WARNING: %r is %d chars, will truncate to %d on "
|
||||
"the companion protocol" % (version, len(version), VER_LIMIT)
|
||||
)
|
||||
print("build_version.py: WARNING: %r is %d chars, will truncate to %d on "
|
||||
"the companion protocol" % (version, len(version), VER_LIMIT))
|
||||
|
||||
# yymmdd hhmm = exactly 11. Not pretty, but complete and sortable; the readable
|
||||
# "%d %b %Y %H:%M" is 17 and lost its time to the 12-byte field.
|
||||
@@ -121,13 +107,11 @@ build_date = now.strftime("%y%m%d %H%M")[:DATE_LIMIT]
|
||||
# the tree is already fully recompiled each time.
|
||||
build_epoch = int(now.timestamp())
|
||||
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
("FIRMWARE_VERSION", env.StringifyMacro(version)),
|
||||
("FIRMWARE_BUILD_DATE", env.StringifyMacro(build_date)),
|
||||
("FIRMWARE_BUILD_EPOCH", str(build_epoch)),
|
||||
# src/helpers/FwUpdate refuses a package built for another env
|
||||
("FW_OTA_TARGET", env.StringifyMacro(env["PIOENV"])),
|
||||
]
|
||||
)
|
||||
env.Append(CPPDEFINES=[
|
||||
("FIRMWARE_VERSION", env.StringifyMacro(version)),
|
||||
("FIRMWARE_BUILD_DATE", env.StringifyMacro(build_date)),
|
||||
("FIRMWARE_BUILD_EPOCH", str(build_epoch)),
|
||||
# src/helpers/FwUpdate refuses a package built for another env
|
||||
("FW_OTA_TARGET", env.StringifyMacro(env["PIOENV"])),
|
||||
])
|
||||
print("build_version.py: %s (Build: %s, epoch %d)" % (version, build_date, build_epoch))
|
||||
Reference in new issue
Block a user