meshberry/scripts/git_version.py
2026-09-24 15:29:13 +02:00

20 lines
389 B
Python

Import("env")
import subprocess
def git(*args):
try:
return subprocess.check_output(
["git"] + list(args), stderr=subprocess.DEVNULL
).strip().decode("ascii")
except Exception:
return None
# count number of commits.
build_number = git("rev-list", "--count", "HEAD") or "0"
env.Append(BUILD_FLAGS=[
"-DBUILD_NUMBER=%s" % build_number
])