include SHA in version strings

pull/791/head
Kevin Hester 2021-04-16 10:35:10 +08:00
rodzic c795b70b6c
commit 1b1431f9ad
1 zmienionych plików z 24 dodań i 3 usunięć

Wyświetl plik

@ -1,16 +1,37 @@
import subprocess
import configparser
import traceback
import sys
Import("projenv")
import configparser
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
config = configparser.RawConfigParser()
config.read(prefsLoc)
version = dict(config.items('VERSION'))
verStr = "{}.{}.{}".format(version["major"], version["minor"], version["build"])
# Try to find current build SHA if if the workspace is clean. This could fail if git is not installed
try:
sha = subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip()
isDirty = subprocess.check_output(
['git', 'diff', 'HEAD']).decode("utf-8").strip()
suffix = sha
if isDirty:
suffix = sha + "-dirty"
verStr = "{}.{}.{}.{}".format(
version["major"], version["minor"], version["build"], suffix)
except:
print("Unexpected error:", sys.exc_info()[0])
traceback.print_exc()
verStr = "{}.{}.{}".format(
version["major"], version["minor"], version["build"])
print("Using meshtastic platform-custom.py, firmare version " + verStr)
# General options that are passed to the C and C++ compilers
projenv.Append(CCFLAGS=[
"-DAPP_VERSION=" + verStr
])
])