(argv: list[str] | None = None)
| 487 | |
| 488 | |
| 489 | def main(argv: list[str] | None = None) -> int: |
| 490 | parser = argparse.ArgumentParser( |
| 491 | description=( |
| 492 | "Detect compiler-flag drift between the fbuild and PlatformIO " |
| 493 | "backends for a single board. Exits non-zero on drift." |
| 494 | ) |
| 495 | ) |
| 496 | parser.add_argument( |
| 497 | "--board", |
| 498 | required=True, |
| 499 | help="Board to check (e.g. teensy41, esp32dev).", |
| 500 | ) |
| 501 | parser.add_argument( |
| 502 | "--example", |
| 503 | default="Blink", |
| 504 | help="Sketch to compile in each backend (default: Blink).", |
| 505 | ) |
| 506 | parser.add_argument( |
| 507 | "--skip-build", |
| 508 | action="store_true", |
| 509 | help=( |
| 510 | "Skip the actual compiles and reuse any existing " |
| 511 | "build_info_*.json files. Fails if neither backend has produced " |
| 512 | "one yet." |
| 513 | ), |
| 514 | ) |
| 515 | parser.add_argument( |
| 516 | "--timeout", |
| 517 | type=int, |
| 518 | default=900, |
| 519 | help="Per-backend compile timeout in seconds (default: 900).", |
| 520 | ) |
| 521 | parser.add_argument( |
| 522 | "--project-root", |
| 523 | type=Path, |
| 524 | default=None, |
| 525 | help="Override the FastLED repo root (default: auto-detect).", |
| 526 | ) |
| 527 | args = parser.parse_args(argv) |
| 528 | |
| 529 | project_root = ( |
| 530 | args.project_root.resolve() |
| 531 | if args.project_root is not None |
| 532 | else Path(__file__).resolve().parent.parent |
| 533 | ) |
| 534 | |
| 535 | # The two backends overwrite the same .build/pio/<board>/build_info_*.json |
| 536 | # file, so we must snapshot fbuild's output BEFORE running pio. The |
| 537 | # --skip-build path only works when the user has already manually staged |
| 538 | # both backends' build_info JSONs (or saved one elsewhere); we don't have |
| 539 | # a way to recover a fresh fbuild snapshot from disk after pio has run. |
| 540 | |
| 541 | fbuild_info: dict |
| 542 | pio_info: dict |
| 543 | |
| 544 | if args.skip_build: |
| 545 | bi_path = _find_build_info(project_root, args.board, args.example, "fbuild") |
| 546 | if bi_path is None: |
no test coverage detected