diff --git a/tools/mkdist.py b/tools/mkdist.py index 528447d..4fe7add 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -17,6 +17,7 @@ bindings.txt keymap) with the pod build as fallback. Usage: python tools/mkdist.py [outdir] (default outdir = dist/) """ import os +import re import subprocess import sys import time @@ -29,10 +30,19 @@ def main(): outdir = sys.argv[1] if len(sys.argv) > 1 else os.path.join(REPO, "dist") os.makedirs(outdir, exist_ok=True) - githash = subprocess.check_output( - ["git", "rev-parse", "--short", "HEAD"]).decode().strip() - stamp = time.strftime("%Y-%m-%d") - name = "BT411-%s-%s" % (stamp, githash) + # Name by the repo version convention (BT411_4.11.NNN, tools/btversion.cmake: + # build = commit count). Falls back to date+hash if the header is absent. + name = None + for h in ("build/btversion.h", "build-glass/btversion.h"): + if os.path.exists(h): + m = re.search(r'BT_VERSION_STRING\s+"([^"]+)"', open(h).read()) + if m: + name = "BT411_" + m.group(1) + break + if name is None: + githash = subprocess.check_output( + ["git", "rev-parse", "--short", "HEAD"]).decode().strip() + name = "BT411-%s-%s" % (time.strftime("%Y-%m-%d"), githash) zpath = os.path.join(outdir, name + ".zip") tracked = subprocess.check_output(