2020-12-10 03:28:15 +00:00
|
|
|
|
|
|
|
|
2021-04-16 02:35:10 +00:00
|
|
|
import subprocess
|
2020-12-10 04:44:35 +00:00
|
|
|
import configparser
|
2021-04-16 02:35:10 +00:00
|
|
|
import traceback
|
|
|
|
import sys
|
|
|
|
|
|
|
|
Import("projenv")
|
|
|
|
|
2020-12-10 05:17:43 +00:00
|
|
|
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
|
2020-12-10 06:04:19 +00:00
|
|
|
config = configparser.RawConfigParser()
|
|
|
|
config.read(prefsLoc)
|
|
|
|
version = dict(config.items('VERSION'))
|
2021-04-16 02:35:10 +00:00
|
|
|
|
|
|
|
# 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"])
|
2020-12-10 03:28:15 +00:00
|
|
|
|
2020-12-25 02:16:49 +00:00
|
|
|
print("Using meshtastic platform-custom.py, firmare version " + verStr)
|
2020-12-10 03:28:15 +00:00
|
|
|
|
|
|
|
# General options that are passed to the C and C++ compilers
|
|
|
|
projenv.Append(CCFLAGS=[
|
2020-12-27 04:53:23 +00:00
|
|
|
"-DAPP_VERSION=" + verStr
|
2021-04-16 02:35:10 +00:00
|
|
|
])
|