1
0
forked from me/IronOS

Let's try in in python translate script directly, to keep support ci process.

Reverted build.sh
This commit is contained in:
GeminiServer
2020-03-19 18:17:20 +01:00
parent 4aabf770cd
commit a5ec2bcfa0
2 changed files with 35 additions and 30 deletions

View File

@@ -7,6 +7,8 @@ import io
from datetime import datetime from datetime import datetime
import sys import sys
import fontTables import fontTables
import re
import subprocess
TRANSLATION_CPP = "Translation.cpp" TRANSLATION_CPP = "Translation.cpp"
@@ -451,29 +453,43 @@ def writeLanguage(languageCode, defs, f):
# ----- Block end # ----- Block end
f.write(to_unicode("#endif\n")) 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(): def read_opts():
""" Reading input parameters """ Reading input parameters
First parameter = build version First parameter = json directory
Second parameter = json directory Second parameter = target directory
Third parameter = target directory
""" """
if len(sys.argv) > 1: if len(sys.argv) > 1:
buildVersion = sys.argv[1] jsonDir = sys.argv[1]
else:
raise Exception("Could not get build version")
if len(sys.argv) > 2:
jsonDir = sys.argv[2]
else: else:
jsonDir = "." jsonDir = "."
if len(sys.argv) > 3:
outFile = sys.argv[3] if len(sys.argv) > 2:
outFile = sys.argv[2]
else: else:
outDir = os.path.relpath(jsonDir + "/../workspace/TS100/Core/Src") outDir = os.path.relpath(jsonDir + "/../workspace/TS100/Core/Src")
outFile = os.path.join(outDir, TRANSLATION_CPP) outFile = os.path.join(outDir, TRANSLATION_CPP)
if len(sys.argv) > 4:
if len(sys.argv) > 3:
raise Exception("Too many parameters!") raise Exception("Too many parameters!")
return jsonDir, outFile, buildVersion
return jsonDir, outFile
def orderOutput(langDict): def orderOutput(langDict):
@@ -499,15 +515,17 @@ def writeTarget(outFile, defs, langCodes):
for langCode in langCodes: for langCode in langCodes:
writeLanguage(langCode, defs, f) writeLanguage(langCode, defs, f)
if __name__ == "__main__": if __name__ == "__main__":
try: try:
jsonDir, outFile, buildVersion = read_opts() jsonDir, outFile = read_opts()
except: except:
print("usage: make_translation.py {build version} {json dir} {cpp dir}") print("usage: make_translation.py {json dir} {cpp dir}")
sys.exit(1) sys.exit(1)
print("Build version string: " + buildVersion) try: buildVersion = readVersion()
except: print("error: could not get/extract build version"); sys.exit(1)
print("Build version: " + buildVersion)
print("Making " + outFile + " from " + jsonDir) print("Making " + outFile + " from " + jsonDir)
langDict = readTranslations(jsonDir) langDict = readTranslations(jsonDir)

View File

@@ -8,7 +8,6 @@ AVAILABLE_LANGUAGES=()
BUILD_LANGUAGES=() BUILD_LANGUAGES=()
AVAILABLE_MODELS=("TS100" "TS80") AVAILABLE_MODELS=("TS100" "TS80")
BUILD_MODELS=() BUILD_MODELS=()
BUILD_VERSION=()
usage () usage ()
{ {
@@ -23,14 +22,6 @@ INFO : By default, without parameters, the build is for all platforms and all la
exit 1 exit 1
} }
buildVersion ()
{
GIT_HASH="$(git describe --always)"
VERSION="$(grep '#define BUILD_VERSION' 'version.h' | awk '{print $3}' | sed 's/"//g')"
BUILD_VERSION=$VERSION'.'$GIT_HASH
echo "Building version: $BUILD_VERSION"
}
checkLastCommand () checkLastCommand ()
{ {
if [ $? -eq 0 ] if [ $? -eq 0 ]
@@ -90,10 +81,6 @@ echo " by Ralim"
echo " " echo " "
echo "*********************************************" echo "*********************************************"
#Get and show build version
buildVersion
echo "*********************************************"
# Calculate available languages # Calculate available languages
for f in "$TRANSLATION_DIR"/translation_*.json for f in "$TRANSLATION_DIR"/translation_*.json
do do
@@ -143,7 +130,7 @@ echo "*********************************************"
if [ ${#BUILD_LANGUAGES[@]} -gt 0 ] && [ ${#BUILD_MODELS[@]} -gt 0 ] if [ ${#BUILD_LANGUAGES[@]} -gt 0 ] && [ ${#BUILD_MODELS[@]} -gt 0 ]
then then
echo "Generating Translation.cpp" echo "Generating Translation.cpp"
python3 "$TRANSLATION_DIR/$TRANSLATION_SCRIPT" "$BUILD_VERSION" "$TRANSLATION_DIR" python3 "$TRANSLATION_DIR/$TRANSLATION_SCRIPT" "$TRANSLATION_DIR"
checkLastCommand checkLastCommand
echo "Cleaning previous builds" echo "Cleaning previous builds"