()
| 183 | |
| 184 | |
| 185 | def main() -> int: |
| 186 | args = parse_args() |
| 187 | here = Path(__file__).parent |
| 188 | project_root = here.parent |
| 189 | build = project_root / ".build" |
| 190 | |
| 191 | if not build.exists(): |
| 192 | print(f"Build directory {build} not found") |
| 193 | return 1 |
| 194 | |
| 195 | if args.board: |
| 196 | # Resolve board name to canonical board_name (handles aliases like blackpill_f411ce → stm32f411ce) |
| 197 | canonical_board_name = resolve_board_name(args.board) |
| 198 | if canonical_board_name != args.board: |
| 199 | print( |
| 200 | f"Resolved board '{args.board}' to canonical name '{canonical_board_name}'" |
| 201 | ) |
| 202 | |
| 203 | # fbuild-backed boards: route cppcheck through the compile DB fbuild |
| 204 | # emits. Avoids `pio check`'s CMake-configure failure mode (missing |
| 205 | # partition CSVs etc.) while giving us real cppcheck coverage, not a |
| 206 | # skip. See FastLED#2303. |
| 207 | if was_compiled_with_fbuild(project_root, build, canonical_board_name): |
| 208 | compile_db = ensure_compile_commands( |
| 209 | project_root, build, canonical_board_name |
| 210 | ) |
| 211 | if compile_db is None: |
| 212 | print( |
| 213 | f"ERROR: could not obtain fbuild compile_commands.json for " |
| 214 | f"'{canonical_board_name}'. fbuild >= 2.1 should emit this " |
| 215 | f"via `fbuild build -e {canonical_board_name} --target " |
| 216 | f"compiledb`; verify the fbuild version and the env name. " |
| 217 | f"Tracking: FastLED#2303.", |
| 218 | file=sys.stderr, |
| 219 | ) |
| 220 | return 1 |
| 221 | return run_static_analysis_against_compile_db(compile_db, project_root) |
| 222 | |
| 223 | # Search for the specified board using the canonical name |
| 224 | project_dir = find_platformio_project_dir(build, canonical_board_name) |
| 225 | if not project_dir: |
| 226 | print( |
| 227 | f"No platformio.ini found for board '{args.board}' (canonical name: '{canonical_board_name}')" |
| 228 | ) |
| 229 | print("This usually means the board hasn't been compiled yet.") |
| 230 | print(f"Try running: uv run ci/ci-compile.py {args.board} --examples Blink") |
| 231 | return 1 |
| 232 | else: |
| 233 | # Auto-detect available board by searching for any platformio.ini |
| 234 | project_dir = None |
| 235 | |
| 236 | # Try to find any platformio.ini file in the build directory |
| 237 | for platformio_ini in build.rglob("platformio.ini"): |
| 238 | project_dir = platformio_ini.parent |
| 239 | print(f"Auto-detected project directory: {project_dir}") |
| 240 | break |
| 241 | |
| 242 | if not project_dir: |
no test coverage detected