Make the built image independent of where it was built.
PlatformIO extra script. Wire it in with, in a project's platformio.ini:
extra_scripts = pre:../../tools/reproducible_build.py
Why this exists
---------------
Every board reports a SHA-256 of its own firmware in its heartbeat, and CI keeps
a registry mapping that digest back to the commit that produced it (see
firmware/tools/which_firmware.py). That only works if the same source produces
the same bytes on every machine.
It did not. `ESP_ERROR_CHECK`, `assert` and the ESP log macros all expand
`__FILE__`, and the compiler sees absolute paths, so the image carried strings
like
/home/aidan/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c
/home/aidan/STAR-daq/firmware/Hotfire_Code/common/SensorHotfireCore.h
baked into the hashed bytes -- the username, the home directory and the checkout
path. The same commit built by two people, or by CI, produced three different
digests, so the digest identified the machine rather than the firmware.
`-ffile-prefix-map=OLD=NEW` rewrites those paths at compile time (it covers
`__FILE__` and the debug info both). GCC compares OLD as a literal prefix of the
path it has already normalised, so the mapping has to be an absolute, canonical
path -- which is why this is a script and not a line of `build_flags`: the header
that leaks sits at `-I../common`, outside `$PROJECT_DIR`, and no interpolation
available in platformio.ini can name its directory without a `..` that then
fails to match.
Keep the replacement names stable. Changing `/star` or `/pio` changes every
digest in the registry.