diff --git a/Translation Editor/make_translation.py b/Translation Editor/make_translation.py index 4edc0bdac9..364489967f 100755 --- a/Translation Editor/make_translation.py +++ b/Translation Editor/make_translation.py @@ -7,12 +7,8 @@ from datetime import datetime import sys import fontTables - -# To cause no confusion with the original firmware version of TS100, -# which actually has the latest firmware version 2.18 -# Lets go ahead start with version 2.20.0001 BETA -# Version String: xx.yy.zzzz TAG --> x:Major y:Minor z:Build TAG: REL | BETA | ALPHA -BUILD_VERSION = 'V2.20.0001 BETA' +import re +import subprocess TRANSLATION_CPP = "Translation.cpp" @@ -101,7 +97,7 @@ def getConstants(): consants.append(('SymbolVolts', 'V')) consants.append(('SymbolDC', 'DC')) consants.append(('SymbolCellCount', 'S')) - consants.append(('SymbolVersionNumber', BUILD_VERSION)) + consants.append(('SymbolVersionNumber', buildVersion)) return consants @@ -457,6 +453,22 @@ def writeLanguage(languageCode, defs, f): # ----- Block end f.write(to_unicode("#endif\n")) +def readVersion(): + with open(os.path.relpath(jsonDir + + "/../workspace/TS100/version.h"),"r") as version_file: + try: + for line in version_file: + if re.findall(r'^.*(?<=(#define)).*(?<=(BUILD_VERSION))', line): + line = re.findall(r'\"(.+?)\"',line) + if line: + version = line[0] + try: version += "."+ subprocess.check_output( + ["git","describe", "--always"]).strip().decode('ascii').upper() + except OSError: version += " git" + finally: + if version_file: + version_file.close(); + return version def read_opts(): """ Reading input parameters @@ -503,7 +515,6 @@ def writeTarget(outFile, defs, langCodes): for langCode in langCodes: writeLanguage(langCode, defs, f) - if __name__ == "__main__": try: jsonDir, outFile = read_opts() @@ -511,6 +522,10 @@ def writeTarget(outFile, defs, langCodes): print("usage: make_translation.py {json dir} {cpp dir}") sys.exit(1) + try: buildVersion = readVersion() + except: print("error: could not get/extract build version"); sys.exit(1) + + print("Build version: " + buildVersion) print("Making " + outFile + " from " + jsonDir) langDict = readTranslations(jsonDir) diff --git a/workspace/TS100/build.sh b/workspace/TS100/build.sh index 7bfff64dec..77181aedeb 100755 --- a/workspace/TS100/build.sh +++ b/workspace/TS100/build.sh @@ -78,6 +78,7 @@ echo " Builder for the" echo " Alternate Open Source Firmware" echo " for Miniware TS100 or TS80" echo " by Ralim" +echo " " echo "*********************************************" # Calculate available languages diff --git a/workspace/TS100/version.h b/workspace/TS100/version.h new file mode 100644 index 0000000000..66e80c4148 --- /dev/null +++ b/workspace/TS100/version.h @@ -0,0 +1,7 @@ +/** + * Firmware build version - format: xx.yy.zzzzzz + * x: Major - y: Minor - z: git short hash generated automaticaly from git + * i.e.: BUILD_VERSION = 'Rel. v2.08' --> Will generated to: 'v2.08.1a2b3c4' + */ + +#define BUILD_VERSION "v2.08"