23 lines
648 B
Python
23 lines
648 B
Python
import binascii
|
|
import time
|
|
from pathlib import Path
|
|
|
|
Import("env")
|
|
|
|
pioenv = env.subst("$PIOENV").upper()
|
|
identity_path = Path(env.subst("$PROJECT_DIR")) / "identities" / f"{pioenv}.identity"
|
|
|
|
if not identity_path.exists():
|
|
raise RuntimeError(f"Missing identity file for {pioenv}: {identity_path}")
|
|
|
|
identity_hex = binascii.hexlify(identity_path.read_bytes()).decode("ascii")
|
|
epoch = int(time.time())
|
|
utc_tag = time.strftime("%Y%m%d_%H%M%S", time.gmtime(epoch))
|
|
|
|
env.Append(
|
|
CPPDEFINES=[
|
|
("LOCAL_IDENTITY_HEX", f'\\"{identity_hex}\\"'),
|
|
("FW_BUILD_EPOCH", str(epoch)),
|
|
("FW_BUILD_UTC", f'\\"{utc_tag}\\"'),
|
|
]
|
|
)
|