Updated build system with firmware hash and release info generator

This commit is contained in:
Mark Qvist 2022-11-01 21:13:11 +01:00
parent bfab1e974d
commit a686fd5577
3 changed files with 42 additions and 2 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
TODO TODO
Release/*.hex Release/*.hex
Release/*.zip Release/*.zip
Release/*.json

View File

@ -1,4 +1,6 @@
prep: prep: prep-avr prep-esp32 prep-samd
prep-avr:
arduino-cli core update-index --config-file arduino-cli.yaml arduino-cli core update-index --config-file arduino-cli.yaml
arduino-cli core install arduino:avr arduino-cli core install arduino:avr
arduino-cli core install unsignedio:avr arduino-cli core install unsignedio:avr
@ -8,6 +10,7 @@ prep-esp32:
arduino-cli core install esp32:esp32 arduino-cli core install esp32:esp32
arduino-cli lib install "Adafruit SSD1306" arduino-cli lib install "Adafruit SSD1306"
arduino-cli lib install "AXP202X_Library" arduino-cli lib install "AXP202X_Library"
arduino-cli lib install "Crypto"
prep-samd: prep-samd:
arduino-cli core update-index --config-file arduino-cli.yaml arduino-cli core update-index --config-file arduino-cli.yaml
@ -86,7 +89,10 @@ upload-mega2560:
release: release-all release: release-all
release-all: release-rnode release-mega2560 release-tbeam release-lora32_v20 release-lora32_v21 release-lora32_v20_extled release-lora32_v21_extled release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v2_extled release-rnode_ng_20 release-rnode_ng_21 release-all: release-rnode release-mega2560 release-tbeam release-lora32_v20 release-lora32_v21 release-lora32_v20_extled release-lora32_v21_extled release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v2_extled release-rnode_ng_20 release-rnode_ng_21 release-hashes
release-hashes:
python ./release_hashes.py > ./Release/release.json
release-rnode: release-rnode:
arduino-cli compile --fqbn unsignedio:avr:rnode -e arduino-cli compile --fqbn unsignedio:avr:rnode -e

33
release_hashes.py Normal file
View File

@ -0,0 +1,33 @@
import os
import json
import hashlib
major_version = None
minor_version = None
target_version = None
file = open("Config.h", "rb")
config_data = file.read().splitlines()
for line in config_data:
dline = line.decode("utf-8").strip()
components = dline.split()
if dline.startswith("#define MAJ_VERS"):
major_version = "%01d" % ord(bytes.fromhex(dline.split()[2].split("x")[1]))
if dline.startswith("#define MIN_VERS"):
minor_version = "%02d" % ord(bytes.fromhex(dline.split()[2].split("x")[1]))
target_version = major_version+"."+minor_version
release_hashes = {}
target_dir = "./Release"
files = os.listdir(target_dir)
for filename in files:
if os.path.isfile(os.path.join(target_dir, filename)):
if filename.startswith("rnode_firmware"):
file = open(os.path.join(target_dir, filename), "rb")
release_hashes[filename] = {
"hash": hashlib.sha256(file.read()).hexdigest(),
"version": target_version
}
print(json.dumps(release_hashes))