From f80f7326b6c87f645cec24e508e123f7b98ffe8a Mon Sep 17 00:00:00 2001 From: zackees Date: Sun, 10 May 2026 08:41:30 -0700 Subject: [PATCH] chore(baseline-205): tighten excluded-libs scan to file field only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous scan globbed every needle (FNET / Snooze / RadioHead / mbedtls) against the entire compile_commands.json entry — file + directory + command + arguments. That caught the framework-wide `-I.../libraries/` header search-path flag on every TU, so the report read "FNET: 68 entries" on teensylc just because the include path was on every translation unit. The actual AC#1 question — "did any FNET source file get compiled?" — was masked. Switch to a path-segment match against the `file` field only: `/libraries//` in the normalized POSIX form. Now the count is "TUs whose `file` is a `/...` source file", which is the question AC#1 asks. With the fix, all four boards (teensylc, teensy30, teensy41, stm32f103c8) report `0 (not compiled)` for every excluded library — AC#1 is met cleanly across the matrix, no hand-reading required. Also reworded the report line from "Excluded library hits in compile_commands.json" → "Excluded-library source files compiled (AC#1 must be 0 for all)" so the report header itself states the contract. Refs: #205 AC#1. Co-Authored-By: Claude Opus 4.7 (1M context) --- ci/measure_baseline_205.py | 38 +++++++++++++++++++++++-------- tasks/baseline-205.md | 46 +++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/ci/measure_baseline_205.py b/ci/measure_baseline_205.py index 41a64ee4..a9030a86 100644 --- a/ci/measure_baseline_205.py +++ b/ci/measure_baseline_205.py @@ -16,8 +16,11 @@ 3. Probes the resulting firmware.elf for ``.text`` / ``.data`` / ``.bss`` / ``.dmabuffers`` section sizes via ``arm-none-eabi-size`` (preferred for ARM targets) or ``llvm-size``. -4. Scans compile_commands.json for FNET / Snooze / RadioHead / mbedtls - entries (the libraries that #204 root-caused as wrongly-selected). +4. Scans compile_commands.json for compiled FNET / Snooze / RadioHead / + mbedtls source files (the libraries that #204 root-caused as + wrongly-selected). Counts are by ``file`` field only — never by the + ``-I.../libraries/`` header search-path flag, which is on every + TU regardless of which sources were compiled. Skipping behaviour: @@ -207,7 +210,20 @@ def generate_compdb(project: Path, env: str) -> tuple[bool, str]: # ── Parsers ────────────────────────────────────────────────────────────────── def parse_compile_commands(path: Path) -> tuple[Optional[int], dict]: - """Return (tu_count, excluded_lib_hits).""" + """Return (tu_count, excluded_lib_hits). + + ``excluded_lib_hits[lib]`` counts TUs whose ``file`` field is under + ``.../libraries//`` — i.e. the library actually had a source + file compiled. We deliberately do NOT scan the ``arguments`` / + ``command`` fields: the framework's full ``-I.../libraries/`` + flag is propagated to every TU as a header search path, so a naive + substring match would report counts equal to the TU count even + when zero ``/*.c`` files were compiled. + + AC#1 from FastLED/fbuild#205 is "FNET / Snooze / RadioHead / + mbedtls are not compiled" — that question is answered by the + ``file`` field alone. + """ try: with path.open(encoding="utf-8") as fh: entries = json.load(fh) @@ -222,11 +238,13 @@ def parse_compile_commands(path: Path) -> tuple[Optional[int], dict]: for entry in entries: if not isinstance(entry, dict): continue - haystack = " ".join( - str(entry.get(key, "")) for key in ("file", "directory", "command", "arguments") - ) + file_field = entry.get("file") + if not isinstance(file_field, str): + continue + # Normalize separators so the same check works on Windows + Unix. + normalized = file_field.replace("\\", "/") for needle in EXCLUDED_LIB_NEEDLES: - if needle.lower() in haystack.lower(): + if f"/libraries/{needle}/" in normalized: hits[needle] += 1 return tu_count, hits @@ -332,10 +350,12 @@ def render_markdown(results: List[TargetResult], git_sha: str, branch: str, carg lines.append(f"- {section}: section absent or size tool unavailable") else: lines.append(f"- {section}: {value:,} bytes") - lines.append("- Excluded library hits in compile_commands.json:") + lines.append( + "- Excluded-library source files compiled (AC#1 must be 0 for all):" + ) for needle in EXCLUDED_LIB_NEEDLES: count = r.excluded_lib_hits.get(needle, 0) - label = "not present" if count == 0 else f"{count} entries" + label = "0 (not compiled)" if count == 0 else f"{count} TU(s) compiled" lines.append(f" - {needle}: {label}") if r.notes: lines.append(f"- Notes: {r.notes}") diff --git a/tasks/baseline-205.md b/tasks/baseline-205.md index eb9e9639..10cc20a2 100644 --- a/tasks/baseline-205.md +++ b/tasks/baseline-205.md @@ -1,8 +1,8 @@ # Baseline measurements for #205 -Captured: 2026-05-10T15:14:08Z -Git SHA: fffb1b4cc6389942bf63cc2ae0f01e65484e10fe -Branch: chore/fix-baseline-205-teensylc-env +Captured: 2026-05-10T15:40:43Z +Git SHA: 52b517511baeba28344e8cb7630aa4772e8420ac +Branch: chore/baseline-205-tighten-excluded-libs-scan Tooling: cargo 1.94.1 (29ea6fb6a 2026-03-24), size tool: arm-none-eabi-size.exe Generated by `uv run python ci/measure_baseline_205.py`. See module docstring for methodology. @@ -16,11 +16,11 @@ Generated by `uv run python ci/measure_baseline_205.py`. See module docstring fo - .data: 380 bytes - .bss: 1,068 bytes - .dmabuffers: 192 bytes -- Excluded library hits in compile_commands.json: - - FNET: 68 entries - - Snooze: 68 entries - - RadioHead: 68 entries - - mbedtls: not present +- Excluded-library source files compiled (AC#1 must be 0 for all): + - FNET: 0 (not compiled) + - Snooze: 0 (not compiled) + - RadioHead: 0 (not compiled) + - mbedtls: 0 (not compiled) ## teensy30 / Blink @@ -31,11 +31,11 @@ Generated by `uv run python ci/measure_baseline_205.py`. See module docstring fo - .data: 272 bytes - .bss: 1,120 bytes - .dmabuffers: 248 bytes -- Excluded library hits in compile_commands.json: - - FNET: 68 entries - - Snooze: 68 entries - - RadioHead: 68 entries - - mbedtls: not present +- Excluded-library source files compiled (AC#1 must be 0 for all): + - FNET: 0 (not compiled) + - Snooze: 0 (not compiled) + - RadioHead: 0 (not compiled) + - mbedtls: 0 (not compiled) ## teensy41 / Blink @@ -46,11 +46,11 @@ Generated by `uv run python ci/measure_baseline_205.py`. See module docstring fo - .data: 3,776 bytes - .bss: 1,664 bytes - .dmabuffers: section absent or size tool unavailable -- Excluded library hits in compile_commands.json: - - FNET: 85 entries - - Snooze: 85 entries - - RadioHead: 85 entries - - mbedtls: not present +- Excluded-library source files compiled (AC#1 must be 0 for all): + - FNET: 0 (not compiled) + - Snooze: 0 (not compiled) + - RadioHead: 0 (not compiled) + - mbedtls: 0 (not compiled) ## stm32f103c8 / Blink @@ -60,11 +60,11 @@ Generated by `uv run python ci/measure_baseline_205.py`. See module docstring fo - .text: 12,192 bytes - .data: 240 bytes - .bss: 1,012 bytes -- Excluded library hits in compile_commands.json: - - FNET: not present - - Snooze: not present - - RadioHead: not present - - mbedtls: not present +- Excluded-library source files compiled (AC#1 must be 0 for all): + - FNET: 0 (not compiled) + - Snooze: 0 (not compiled) + - RadioHead: 0 (not compiled) + - mbedtls: 0 (not compiled) ## Build status