added version to firmware filename

This commit is contained in:
Paul Derbyshire
2019-07-16 16:25:56 +02:00
parent c3bc82cbc8
commit d5c717c812

View File

@@ -1,7 +1,27 @@
#!/usr/bin/env python #!/usr/bin/env python
import re
Import("env") Import("env")
# see http://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#before-pre-and-after-post-actions bag = {}
# env.Replace(PROGNAME="firmware_%s" % defines.get("VERSION")) exprs = [
# print env.Dump() (re.compile(r'^#define APP_VERSION\s+"(\S+)"'), 'app_version'),
env.Replace(PROGNAME="firmware_%s" % env['BOARD'] + "_" + env['PIOENV']) (re.compile(r'^#define APP_NAME\s+"(\S+)"'), 'app_name'),
(re.compile(r'^#define APP_HOSTNAME\s+"(\S+)"'), 'app_hostname'),
]
with open('./src/version.h', 'r') as f:
for l in f.readlines():
for expr, var in exprs:
m = expr.match(l)
if m and len(m.groups()) > 0:
bag[var] = m.group(1)
app_version = bag.get('app_version')
app_name = bag.get('app_name')
app_hostname = bag.get('app_hostname')
board = env['BOARD']
branch = env['PIOENV']
# build filename, replacing . with _ for the version
env.Replace(PROGNAME="firmware_%s" % branch + "_" + app_version.replace(".", "_"))