Import("env") import hashlib import json from pathlib import Path def after_build(source, target, env): firmware = Path(str(target[0])) if not firmware.exists(): return data = firmware.read_bytes() metadata = { "firmware": str(firmware), "file_size_bytes": len(data), "sha256": hashlib.sha256(data).hexdigest(), "platformio_env": env["PIOENV"], } output = firmware.with_suffix(".espverse.json") output.write_text(json.dumps(metadata, indent=2), encoding="utf-8") print(f"ESPVerse metadata written to {output}") env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", after_build)