27 lines
850 B
Python
Executable file
27 lines
850 B
Python
Executable file
#!/usr/bin/env python3
|
|
"""Pre-build: generate src/version.h from version.txt so the firmware
|
|
uses the single source of truth for version numbers."""
|
|
Import("env")
|
|
import os
|
|
|
|
project_dir = env.subst("$PROJECT_DIR")
|
|
ver_file = os.path.join(project_dir, "version.txt")
|
|
out_file = os.path.join(project_dir, "src", "version.h")
|
|
|
|
versions = {}
|
|
with open(ver_file) as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if "=" in line:
|
|
k, v = line.split("=", 1)
|
|
versions[k.strip()] = v.strip()
|
|
|
|
header = f"""// Auto-generated from version.txt — DO NOT EDIT
|
|
#define FIRMWARE_VERSION_SERVER "{versions['server']}"
|
|
#define FIRMWARE_VERSION_CLIENT "{versions['client']}"
|
|
"""
|
|
|
|
with open(out_file, "w") as f:
|
|
f.write(header)
|
|
|
|
print(f" versions: server={versions['server']} client={versions['client']} -> src/version.h")
|