Skip to content

fbuild: integrate with clang-tool-chain-bin for IWYU and C++ static analysis #2303

Closed

Description

@zackees

Problem

FastLED's C++ static analysis pipeline today is PlatformIO-bound:

Tool Entry point Backend assumption
cppcheck ci/ci-cppcheck.py → pio check Requires a fully-populated PIO project tree
include-what-you-use ci/ci-iwyu.py → find_platformio_project_dir() → clang-tool-chain-iwyu Uses PIO project dir to find compile_commands.json

Both scripts look for .build/pio/<board>/<Example>/platformio.ini, cd into it, then run the tool against that PIO project. When fbuild is the active backend (esp32c2 today, expanding), the PIO project tree either doesn't exist or is missing the files the tools need — pio check fails because PIO can't resolve huge_app.csv, and IWYU can't find a valid compile_commands.json.

Rolling back affected boards to PIO every time would defeat the whole point of the fbuild migration.

Proposal

Make fbuild a first-class citizen for static analysis and include management by integrating with github.com/zackees/clang-tool-chain-bin. That toolchain already ships the wrappers FastLED uses today:

  • clang-tool-chain-cpp — portable C++ compiler wrapper (already referenced in ci/build_example.toml lines 53, 169 and used throughout ci/ci-iwyu.py)
  • clang-tool-chain-iwyu — IWYU wrapper (already used via uv run clang-tool-chain-iwyu, see ci/ci-iwyu.py:602)

All of these need a compile_commands.json and source tree — not a PIO project tree. fbuild already produces compile commands via its daemon; exposing them to these tools is a much lighter integration than reconstructing a PIO project every time.

Concrete work items

  1. fbuild → compile_commands.json export. Confirm / add an API in ci/util/fbuild_adapter.py for get_compile_commands(board, example) -> Path. If fbuild already writes .fbuild/build/<env>/compile_commands.json, expose that path; otherwise, generate it from the daemon's build state.
  2. ci/ci-iwyu.py — backend-aware path. Detect fbuild vs PIO, point IWYU at the fbuild compile-commands file when fbuild is active. Drop the find_platformio_project_dir() hard dependency.
  3. ci/ci-cppcheck.py — same rework. Run cppcheck directly via clang-tool-chain rather than pio check when fbuild is active (this also frees cppcheck from PIO's CMake-configure failure mode — see fbuild: add cppcheck / static-analysis support (currently PIO-only) #2301).
  4. Other linting/analysis tools. Once the pattern is in place, add wrappers for whatever else clang-tool-chain-bin ships that we want in CI (clang-tidy, clang-format-check, etc.).

Why clang-tool-chain-bin?

  • Already an approved dependency — referenced in ci/build_example.toml and ci/ci-iwyu.py.
  • Ships prebuilt binaries cross-platform (Windows / macOS / Linux) so CI doesn't have to compile LLVM tooling.
  • Same wrapper API for every tool → minimal per-tool glue in FastLED CI scripts.

Relation to existing issues

This issue is the umbrella for making fbuild-compiled boards fully covered by our static-analysis stack via clang-tool-chain-bin. #2301 can be considered a subset and closed as part of this, or kept as the narrower cppcheck tracker and closed by the same PR that lands item (3) above.

Acceptance

  • ci/ci-iwyu.py and ci/ci-cppcheck.py run successfully on esp32c2 (and any other fbuild-default board) without needing a PIO project tree.
  • Adding future clang-tool-chain-bin tools (clang-tidy, clang-format, etc.) to CI is a ~10 LOC change, not a fresh port.
  • No regression on PIO-backed boards.

Activity

  1. zackees commented on Apr 19, 2026

    @zackees
    MemberAuthor

    Closing — all acceptance criteria met:

    (1) fbuild → compile_commands.json export. Done via ci/util/fbuild_adapter.py::get_compile_commands() (imported and used by both entry points).

    (2) ci/ci-iwyu.py backend-aware path. Done — now imports get_compile_commands from fbuild_adapter and routes through clang-tool-chain-iwyu-tool when fbuild is the active backend. PIO path retained as legacy fallback.

    (3) ci/ci-cppcheck.py same rework. Done — imports ensure_compile_commands and was_compiled_with_fbuild from fbuild_compiledb; fbuild-backed boards are routed through the compile DB rather than pio check.

    (4) Framework for future clang-tool-chain-bin tools. Landed via shared fbuild_adapter/fbuild_compiledb helpers.

    Merged in: #2307 (phase A routing), #2331 (IWYU + cppcheck PIO decouple), #2338 (IWYU fail-fast on missing mappings), #2345 (final CodeRabbit nits). Verified: esp32c2 CI runs under fbuild without a PIO project tree; PIO-backed boards unchanged. Reopen if a gap surfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions