Extracted webroot into usable files

This commit is contained in:
Gunnar Skjold
2020-01-31 21:08:27 +01:00
parent ced6f125fd
commit fc1f1554d8
14 changed files with 51 additions and 414 deletions

16
scripts/addversion.py Normal file
View File

@@ -0,0 +1,16 @@
import os
FILENAME_VERSION_H = 'src/version.h'
version = os.environ.get('GITHUB_REF')
if version == None:
version = "SNAPSHOT"
import datetime
hf = """
#ifndef VERSION
#define VERSION "{}"
#endif
""".format(version)
with open(FILENAME_VERSION_H, 'w+') as f:
f.write(hf)

25
scripts/makeweb.py Normal file
View File

@@ -0,0 +1,25 @@
import os
import re
webroot = "web"
srcroot = "src/web/root"
if not os.path.exists(srcroot):
os.mkdir(srcroot)
for filename in os.listdir(webroot):
basename = re.sub("[^0-9a-zA-Z]+", "_", filename)
srcfile = webroot + "/" + filename
dstfile = srcroot + "/" + basename + ".h"
varname = basename.upper()
with open(dstfile, "w") as dst:
dst.write("const char ")
dst.write(varname)
dst.write("[] PROGMEM = R\"==\"==(\n")
with open(srcfile, "r") as src:
for line in src.readlines():
dst.write(line)
dst.write("\n)==\"==\";\n")