mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-03 23:14:15 +01:00
* utils/version: use git description token as version, add memoization * pio: move extra scripts to a separate directory * pio: add -DAPP_REVISION=... as local build flag
24 lines
596 B
Python
24 lines
596 B
Python
import os
|
|
import subprocess
|
|
|
|
def git(*args):
|
|
cmd = ["git"]
|
|
cmd.extend(args)
|
|
proc = subprocess.Popen(
|
|
cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True
|
|
)
|
|
return proc.stdout.readlines()[0].strip()
|
|
|
|
def app_inject_revision(env):
|
|
revision = ""
|
|
try:
|
|
revision = "\\\"{}\\\"".format(git("rev-parse", "--short=8", "HEAD"))
|
|
except: # pylint: disable=broad-except
|
|
pass
|
|
|
|
# Note: code expects this as undefined when empty
|
|
if revision:
|
|
env.Append(CPPDEFINES=[
|
|
("APP_REVISION", revision)
|
|
])
|