Return the path to ``compile_commands.json`` for ``board``. Thin wrapper around :func:`ci.util.fbuild_compiledb.ensure_compile_commands` that serves as the public, stable entry point for static-analysis tools (``ci/ci-iwyu.py``, ``ci/ci-cppcheck.py``, future ``clang-tidy`` / ``clang
(board: str, build_root: Path)
| 31 | |
| 32 | |
| 33 | def get_compile_commands(board: str, build_root: Path) -> Path | None: |
| 34 | """Return the path to ``compile_commands.json`` for ``board``. |
| 35 | |
| 36 | Thin wrapper around :func:`ci.util.fbuild_compiledb.ensure_compile_commands` |
| 37 | that serves as the public, stable entry point for static-analysis tools |
| 38 | (``ci/ci-iwyu.py``, ``ci/ci-cppcheck.py``, future ``clang-tidy`` / |
| 39 | ``clang-format-check`` front-ends) to obtain an fbuild-produced compile |
| 40 | database without reaching into the implementation module directly. |
| 41 | |
| 42 | If fbuild has already emitted the database for this board, its existing |
| 43 | path is returned. Otherwise fbuild is invoked with |
| 44 | ``fbuild <project> build -e <board> --target compiledb`` to materialize it. |
| 45 | |
| 46 | Args: |
| 47 | board: Canonical board / fbuild environment name (e.g. ``"esp32c2"``). |
| 48 | build_root: The ``.build/`` directory — where fbuild writes its |
| 49 | artifacts under ``.fbuild/build/<env>/``. Callers know their build |
| 50 | root; no default is applied (per repo style: parameters don't have |
| 51 | defaults). |
| 52 | |
| 53 | Returns: |
| 54 | Path to ``compile_commands.json`` on success, ``None`` if fbuild |
| 55 | couldn't produce one (binary missing, build failure, etc.). |
| 56 | """ |
| 57 | # Local import: keep this module importable even when fbuild isn't |
| 58 | # installed, so callers that only need the identity-probe helpers |
| 59 | # (``is_fbuild_available``) stay lightweight. |
| 60 | from ci.util.fbuild_compiledb import ensure_compile_commands |
| 61 | |
| 62 | project_root = Path(__file__).resolve().parent.parent.parent |
| 63 | return ensure_compile_commands(project_root, build_root, board) |
| 64 | |
| 65 | |
| 66 | def is_fbuild_available() -> bool: |
no test coverage detected