include SHA in version strings

1.2-legacy
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,12 +1,33 @@
import subprocess
import configparser
import traceback
import sys
Import("projenv") Import("projenv")
import configparser
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties" prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
config = configparser.RawConfigParser() config = configparser.RawConfigParser()
config.read(prefsLoc) config.read(prefsLoc)
version = dict(config.items('VERSION')) 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) print("Using meshtastic platform-custom.py, firmare version " + verStr)