refactor: factor out autoversioning.py

BREAKING CHANGE
This commit is contained in:
ZanzyTHEbar 2023-01-11 19:21:50 +00:00
parent b51c9953ed
commit 09b622b923
3 changed files with 3 additions and 32 deletions

View File

@ -224,7 +224,6 @@ monitor_filters =
esp32_exception_decoder
board_build.partitions = min_spiffs.csv
build_flags =
!python tools/autoversioning.py
!python tools/git_rev.py
-DENABLE_ADHOC=${wifi.enableadhoc}

View File

@ -1,28 +0,0 @@
FILENAME_VERSION = 'tools/version.txt'
build_no = 'v0.0.0'
try:
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 = "v0.0.1"
with open(FILENAME_VERSION, 'w+') as f:
f.write(build_no)
print("-DVERSION={0}".format(build_no))

View File

@ -7,8 +7,8 @@ project = project.split("/")
project = project[len(project)-1]
# Get 0.0.0 version from latest Git tag
#tagcmd = "git describe --tags --abbrev=0"
#version = subprocess.check_output(tagcmd, shell=True).decode().strip()
tagcmd = "git describe --tags --abbrev=0"
version = subprocess.check_output(tagcmd, shell=True).decode().strip()
# Get latest commit short from Git
revcmd = "git log --pretty=format:'%h' -n 1"
@ -20,6 +20,6 @@ branch = subprocess.check_output(branchcmd, shell=True).decode().strip()
# Make all available for use in the macros
print("-DPIO_SRC_NAM={0}".format(project))
#print("-DPIO_SRC_TAG={0}".format(version))
print("-DPIO_SRC_TAG={0}".format(version))
print("-DPIO_SRC_REV={0}".format(commit))
print("-DPIO_SRC_BRH={0}".format(branch))