From 6e210485aefdc33a7cef3e460b579252735a6872 Mon Sep 17 00:00:00 2001 From: ZanzyTHEbar Date: Mon, 26 Dec 2022 23:10:11 +0000 Subject: [PATCH] update - remove old versioning system - add new custom firmware name handler --- ESP/tools/autoversioning.py | 38 +++++++++++++++++++++++++------------ ESP/tools/customname.py | 12 ++++++++++++ ESP/tools/firmware_name.txt | 2 +- ESP/tools/version.txt | 1 + ESP/tools/versioning | 1 - 5 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 ESP/tools/version.txt delete mode 100644 ESP/tools/versioning diff --git a/ESP/tools/autoversioning.py b/ESP/tools/autoversioning.py index b6833e5..2a8c198 100644 --- a/ESP/tools/autoversioning.py +++ b/ESP/tools/autoversioning.py @@ -1,14 +1,28 @@ -FILENAME_BUILDNO = 'tools/versioning' -version = 'v0.1.' -build_no = 0 - +FILENAME_VERSION = 'tools/version.txt' +build_no = 'v0.0.0' try: - with open(FILENAME_BUILDNO) as f: - build_no = int(f.readline()) + 1 + with open(FILENAME_VERSION) as f: + build_no = f.readline() + if build_no == '': + raise Exception("Empty file") + version = build_no.split('v') + version = version[1].split('.') + first_num = int(version[0]) + second_num = int(version[1]) + last_num = int(version[2]) + if last_num <= 9: + last_num += 1 + elif second_num <= 9 and last_num >= 9: + second_num += 1 + elif second_num and last_num >= 9: + first_num += 1 + second_num = 0 + last_num = 0 + else: + raise Exception("Invalid version number") + build_no = 'v' + str(first_num) + '.' + str(second_num) + '.' + str(last_num) except: - build_no = 1 -with open(FILENAME_BUILDNO, 'w+') as f: - f.write(str(build_no)) - -#print("-DVERSION=\"%s\"" % version+str(build_no)) -print("-DVERSION={0}".format(version+str(build_no))) + build_no = "v0.0.1" +with open(FILENAME_VERSION, 'w+') as f: + f.write(build_no) +print("-DVERSION={0}".format(build_no)) diff --git a/ESP/tools/customname.py b/ESP/tools/customname.py index 5ed8b94..f0b16c2 100644 --- a/ESP/tools/customname.py +++ b/ESP/tools/customname.py @@ -2,6 +2,9 @@ Import("env") +# Dump global construction environment (for debug purpose) +#print(env.Dump()) + my_flags = env.ParseFlags(env['BUILD_FLAGS']) defines = dict() for x in my_flags.get("CPPDEFINES"): @@ -21,3 +24,12 @@ env.Replace( PROGNAME="%s-%s-%s-%s-%s" % (s(defines.get("PIO_SRC_NAM")), s(defines.get("VERSION")), str(env["PIOENV"]), s(defines.get("PIO_SRC_REV")), s(defines.get("PIO_SRC_BRH")))) + +#detect if there is a forward slash in the PROGNAME and replace it with an underscore +if "/" in env["PROGNAME"]: + env.Replace( + PROGNAME="%s" % + (env["PROGNAME"].replace("/", "-"))) + +# create a file with the name of the firmware +env.Execute("echo %s > %s" % (env["PROGNAME"], env.subst("./tools/firmware_name.txt"))) \ No newline at end of file diff --git a/ESP/tools/firmware_name.txt b/ESP/tools/firmware_name.txt index 497659c..567568d 100644 --- a/ESP/tools/firmware_name.txt +++ b/ESP/tools/firmware_name.txt @@ -1 +1 @@ -OpenIris-v0.1.685-esp32Cam_release-400bd99-feature-mdns-autodiscovery +OpenIris-v0.0.1-esp32Cam_release-be1530b-feature-mdns-autodiscovery diff --git a/ESP/tools/version.txt b/ESP/tools/version.txt new file mode 100644 index 0000000..60453e6 --- /dev/null +++ b/ESP/tools/version.txt @@ -0,0 +1 @@ +v1.0.0 \ No newline at end of file diff --git a/ESP/tools/versioning b/ESP/tools/versioning deleted file mode 100644 index 51f1d23..0000000 --- a/ESP/tools/versioning +++ /dev/null @@ -1 +0,0 @@ -566 \ No newline at end of file