26 lines
677 B
Python
26 lines
677 B
Python
Import("env")
|
|
|
|
from pathlib import Path
|
|
import hashlib
|
|
|
|
|
|
print("Current CLI targets", COMMAND_LINE_TARGETS)
|
|
print("Current Build targets", BUILD_TARGETS)
|
|
|
|
def sha256sum(filename):
|
|
with open(filename, 'rb', buffering=0) as f:
|
|
return hashlib.file_digest(f, 'sha256').hexdigest()
|
|
|
|
def post_buildprog_action(source, target, env):
|
|
source_path = Path(source[0].get_abspath())
|
|
sha256 = sha256sum(source_path)
|
|
print(f"Calculated SHA256: {sha256}")
|
|
|
|
build_dir = source_path.parent
|
|
sha_txt_file = build_dir / "firmware.bin.sha256"
|
|
|
|
with Path.open(sha_txt_file, "w") as f:
|
|
f.write(sha256)
|
|
|
|
env.AddPostAction("buildprog", post_buildprog_action)
|