Skip to content

Commit f80f732

Browse files
zackeesclaude
andcommitted
chore(baseline-205): tighten excluded-libs scan to file field only
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/<lib>` 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/<needle>/` in the normalized POSIX form. Now the count is "TUs whose `file` is a `<needle>/...` 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) <noreply@anthropic.com>
1 parent 6b7fb4b commit f80f732

2 files changed

Lines changed: 52 additions & 32 deletions

File tree

ci/measure_baseline_205.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
3. Probes the resulting firmware.elf for ``.text`` / ``.data`` / ``.bss`` /
1717
``.dmabuffers`` section sizes via ``arm-none-eabi-size`` (preferred for
1818
ARM targets) or ``llvm-size``.
19-
4. Scans compile_commands.json for FNET / Snooze / RadioHead / mbedtls
20-
entries (the libraries that #204 root-caused as wrongly-selected).
19+
4. Scans compile_commands.json for compiled FNET / Snooze / RadioHead /
20+
mbedtls source files (the libraries that #204 root-caused as
21+
wrongly-selected). Counts are by ``file`` field only — never by the
22+
``-I.../libraries/<lib>`` header search-path flag, which is on every
23+
TU regardless of which sources were compiled.
2124
2225
Skipping behaviour:
2326
@@ -207,7 +210,20 @@ def generate_compdb(project: Path, env: str) -> tuple[bool, str]:
207210

208211
# ── Parsers ──────────────────────────────────────────────────────────────────
209212
def parse_compile_commands(path: Path) -> tuple[Optional[int], dict]:
210-
"""Return (tu_count, excluded_lib_hits)."""
213+
"""Return (tu_count, excluded_lib_hits).
214+
215+
``excluded_lib_hits[lib]`` counts TUs whose ``file`` field is under
216+
``.../libraries/<lib>/`` — i.e. the library actually had a source
217+
file compiled. We deliberately do NOT scan the ``arguments`` /
218+
``command`` fields: the framework's full ``-I.../libraries/<lib>``
219+
flag is propagated to every TU as a header search path, so a naive
220+
substring match would report counts equal to the TU count even
221+
when zero ``<lib>/*.c`` files were compiled.
222+
223+
AC#1 from FastLED/fbuild#205 is "FNET / Snooze / RadioHead /
224+
mbedtls are not compiled" — that question is answered by the
225+
``file`` field alone.
226+
"""
211227
try:
212228
with path.open(encoding="utf-8") as fh:
213229
entries = json.load(fh)
@@ -222,11 +238,13 @@ def parse_compile_commands(path: Path) -> tuple[Optional[int], dict]:
222238
for entry in entries:
223239
if not isinstance(entry, dict):
224240
continue
225-
haystack = " ".join(
226-
str(entry.get(key, "")) for key in ("file", "directory", "command", "arguments")
227-
)
241+
file_field = entry.get("file")
242+
if not isinstance(file_field, str):
243+
continue
244+
# Normalize separators so the same check works on Windows + Unix.
245+
normalized = file_field.replace("\\", "/")
228246
for needle in EXCLUDED_LIB_NEEDLES:
229-
if needle.lower() in haystack.lower():
247+
if f"/libraries/{needle}/" in normalized:
230248
hits[needle] += 1
231249
return tu_count, hits
232250

@@ -332,10 +350,12 @@ def render_markdown(results: List[TargetResult], git_sha: str, branch: str, carg
332350
lines.append(f"- {section}: section absent or size tool unavailable")
333351
else:
334352
lines.append(f"- {section}: {value:,} bytes")
335-
lines.append("- Excluded library hits in compile_commands.json:")
353+
lines.append(
354+
"- Excluded-library source files compiled (AC#1 must be 0 for all):"
355+
)
336356
for needle in EXCLUDED_LIB_NEEDLES:
337357
count = r.excluded_lib_hits.get(needle, 0)
338-
label = "not present" if count == 0 else f"{count} entries"
358+
label = "0 (not compiled)" if count == 0 else f"{count} TU(s) compiled"
339359
lines.append(f" - {needle}: {label}")
340360
if r.notes:
341361
lines.append(f"- Notes: {r.notes}")

tasks/baseline-205.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Baseline measurements for #205
22

3-
Captured: 2026-05-10T15:14:08Z
4-
Git SHA: fffb1b4cc6389942bf63cc2ae0f01e65484e10fe
5-
Branch: chore/fix-baseline-205-teensylc-env
3+
Captured: 2026-05-10T15:40:43Z
4+
Git SHA: 52b517511baeba28344e8cb7630aa4772e8420ac
5+
Branch: chore/baseline-205-tighten-excluded-libs-scan
66
Tooling: cargo 1.94.1 (29ea6fb6a 2026-03-24), size tool: arm-none-eabi-size.exe
77

88
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
1616
- .data: 380 bytes
1717
- .bss: 1,068 bytes
1818
- .dmabuffers: 192 bytes
19-
- Excluded library hits in compile_commands.json:
20-
- FNET: 68 entries
21-
- Snooze: 68 entries
22-
- RadioHead: 68 entries
23-
- mbedtls: not present
19+
- Excluded-library source files compiled (AC#1 must be 0 for all):
20+
- FNET: 0 (not compiled)
21+
- Snooze: 0 (not compiled)
22+
- RadioHead: 0 (not compiled)
23+
- mbedtls: 0 (not compiled)
2424

2525
## teensy30 / Blink
2626

@@ -31,11 +31,11 @@ Generated by `uv run python ci/measure_baseline_205.py`. See module docstring fo
3131
- .data: 272 bytes
3232
- .bss: 1,120 bytes
3333
- .dmabuffers: 248 bytes
34-
- Excluded library hits in compile_commands.json:
35-
- FNET: 68 entries
36-
- Snooze: 68 entries
37-
- RadioHead: 68 entries
38-
- mbedtls: not present
34+
- Excluded-library source files compiled (AC#1 must be 0 for all):
35+
- FNET: 0 (not compiled)
36+
- Snooze: 0 (not compiled)
37+
- RadioHead: 0 (not compiled)
38+
- mbedtls: 0 (not compiled)
3939

4040
## teensy41 / Blink
4141

@@ -46,11 +46,11 @@ Generated by `uv run python ci/measure_baseline_205.py`. See module docstring fo
4646
- .data: 3,776 bytes
4747
- .bss: 1,664 bytes
4848
- .dmabuffers: section absent or size tool unavailable
49-
- Excluded library hits in compile_commands.json:
50-
- FNET: 85 entries
51-
- Snooze: 85 entries
52-
- RadioHead: 85 entries
53-
- mbedtls: not present
49+
- Excluded-library source files compiled (AC#1 must be 0 for all):
50+
- FNET: 0 (not compiled)
51+
- Snooze: 0 (not compiled)
52+
- RadioHead: 0 (not compiled)
53+
- mbedtls: 0 (not compiled)
5454

5555
## stm32f103c8 / Blink
5656

@@ -60,11 +60,11 @@ Generated by `uv run python ci/measure_baseline_205.py`. See module docstring fo
6060
- .text: 12,192 bytes
6161
- .data: 240 bytes
6262
- .bss: 1,012 bytes
63-
- Excluded library hits in compile_commands.json:
64-
- FNET: not present
65-
- Snooze: not present
66-
- RadioHead: not present
67-
- mbedtls: not present
63+
- Excluded-library source files compiled (AC#1 must be 0 for all):
64+
- FNET: 0 (not compiled)
65+
- Snooze: 0 (not compiled)
66+
- RadioHead: 0 (not compiled)
67+
- mbedtls: 0 (not compiled)
6868

6969
## Build status
7070

0 commit comments

Comments
 (0)