mirror of
https://github.com/Colorado-Mesh/meshcore-bot-firmware.git
synced 2026-08-11 08:10:29 +00:00
5.0 KiB
5.0 KiB
Step 2 Execution Plan: Add representative build and size-report tooling
Goal
Create local and CI tooling that applies the MeshCore patch queue, builds the four representative companion environments, captures per-environment logs/artifacts, and emits a deterministic size JSON summary.
Current Code Observations
vendor/MeshCore/build.shprovidesbuild-firmware <target>and copies artifacts to its ownout/directory after each build.vendor/MeshCore/build.shremovesvendor/MeshCore/outat startup, so wrapper tooling must copy artifacts after each environment build before starting the next one.vendor/MeshCore/build.shrequiresFIRMWARE_VERSIONin the environment and uses the current MeshCore git SHA in artifact filenames.- Upstream CI installs Python 3.11 and PlatformIO with
pip install --upgrade platformio, then runsbuild.sh build-companion-firmwares. - Representative envs exist in
variants/heltec_v3/platformio.iniandvariants/rak4631/platformio.ini; RAK4631 companion envs setboard_upload.maximum_size = 712704. - The wrapper currently has no
.gitignore, no.github/workflows/, and no build output tooling.
Files to Change
scripts/build-representative.sh— new wrapper build script for patch application, four-env builds, logs, copied artifacts, and size summary generation.scripts/parse-size-report.py— new parser for PlatformIO RAM/flash output plus artifact byte sizes, with optional baseline/compare support..github/workflows/firmware-build.yml— new GitHub Actions workflow using the same representative build script as local development..gitignore— ignore generatedout/and local PlatformIO/cache artifacts if needed.README.md— add the local representative build command and output locations.
Ordered Implementation Checklist
- Add output ignores for wrapper-level generated build artifacts.
- Implement
scripts/parse-size-report.pywith ANSI stripping, PlatformIO RAM/flash line parsing, artifact byte discovery, deterministic JSON output, and optional--baseline/--compare <json>arguments. - Implement
scripts/build-representative.shwith--help,--baseline,--compare <baseline-json>, PlatformIO availability checks, patch application, per-envbuild.sh build-firmwareinvocation, per-env log capture, artifact copying, and parser invocation. - Ensure
build-representative.shusesREPRESENTATIVE_ENVSfromscripts/meshcore-env.sh, sets a defaultFIRMWARE_VERSIONwhen absent, and preserves each env result rather than hiding failures. - Add
.github/workflows/firmware-build.ymlto check out submodules, install Python 3.11 and PlatformIO, runbash scripts/build-representative.sh --baseline, and uploadout/sizeplusout/firmwareartifacts. - Update
README.mdwith the representative build command and generated output paths. - Run shell syntax and Python compile checks, then run script help and the parser against a small synthetic log fixture without requiring PlatformIO.
- If PlatformIO is available locally, run the full baseline build; otherwise record that full build verification is deferred to CI or a local PlatformIO install.
Interfaces and Data Contracts
scripts/build-representative.sh [--baseline|--compare <baseline-json>]builds all envs fromREPRESENTATIVE_ENVSand writes outputs under wrapper-levelout/.scripts/build-representative.sh --helpprints usage and exits successfully without requiring PlatformIO.scripts/parse-size-report.py --logs <log-dir> --artifacts <artifact-dir> [--baseline|--compare <baseline-json>] [--output <json>]emits JSON containing:modegenerated_atenvironments[]- per-env
env,ram_used,ram_total,flash_used,flash_total,artifact_bytes,log,metrics_found, and optionaldelta
- Missing RAM/flash metrics are represented as
nullandmetrics_found: false; the parser must not invent successful measurements. - CI must use the same local scripts instead of duplicating build logic.
Verification Plan
- Automated:
bash -n scripts/build-representative.sh scripts/meshcore-env.shpython3 -m py_compile scripts/parse-size-report.pybash scripts/build-representative.sh --help- Run
scripts/parse-size-report.pyagainst a synthetic log/artifact directory. - If PlatformIO is installed:
bash scripts/build-representative.sh --baseline
- Manual:
- Review generated JSON shape from the synthetic parser run.
- Confirm workflow env list comes from the wrapper script, not a duplicated matrix.
- Regression:
bash scripts/apply-patches.shstill succeeds with an empty patch queue.- Step 1 patch scripts remain unchanged in behavior.
Stop Conditions
- Pause if upstream build env names differ from the planned four representative environments.
- Pause if implementing baseline comparison would require committing generated firmware artifacts.
- Pause if local PlatformIO installation or firmware build requires destructive cleanup outside wrapper-level
out/or upstream.piobuild directories.