diff options
| author | Marin Ivanov <[email protected]> | 2024-08-21 04:00:28 +0300 |
|---|---|---|
| committer | Marin Ivanov <[email protected]> | 2024-08-21 04:00:28 +0300 |
| commit | 2c417fb8398eda685c5dd1f7b1bec811757dc562 (patch) | |
| tree | b2abfbeeaeed5f284629e29d0e991e3d4445e5f2 /build.py | |
| parent | 8354a7fae28e0bcc7a0eb1b6337f6da0d0769c94 (diff) | |
make build system
Diffstat (limited to 'build.py')
| -rw-r--r-- | build.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/build.py b/build.py new file mode 100644 index 0000000..e0b0134 --- /dev/null +++ b/build.py @@ -0,0 +1,28 @@ +import sys, json, tomllib, zlib + +inputs = ["config.toml", "main.css", "main.js", "index.html"] +files = {} +for name in inputs: + with open(name,'r') as f: + files[name] = f.read() + +config = tomllib.loads(files["config.toml"]) +configjson = json.dumps(config, separators=(',',':')) + +index = files["index.html"] +index = index.replace('<link rel="stylesheet" href="style.css">', f'<style>{files["main.css"]}</style>') +index = index.replace('<script src="config.js"></script>', '') +index = index.replace('<script src="ka.js"></script>', '') +index = index.replace('<script src="app.js"></script>', f'<script>config={configjson};{files["main.js"]}</script>') + +data = zlib.compress(index.encode('utf-8')) +out = ', '.join(hex(x) for x in data) +print(f""" +#include <avr/pgmspace.h> +#include "webif-fs.h" + +const char index_html_data[] PROGMEM = {{ {out} }}; +uint16_t index_html_size = {len(data)}; +""") + + |
