Check that _build.cpp.hpp files include ALL immediate subdirectory _build.cpp.hpp files. For each _build.cpp.hpp, every immediate subdirectory that: 1. Contains its own _build.cpp.hpp 2. Is NOT independently compiled by a build file in src/fl/build/ ...must be included. This c
(
src_dir: Path, independently_compiled_dirs: set[str]
)
| 487 | |
| 488 | |
| 489 | def _check_subdir_completeness( |
| 490 | src_dir: Path, independently_compiled_dirs: set[str] |
| 491 | ) -> list[str]: |
| 492 | """ |
| 493 | Check that _build.cpp.hpp files include ALL immediate subdirectory _build.cpp.hpp files. |
| 494 | |
| 495 | For each _build.cpp.hpp, every immediate subdirectory that: |
| 496 | 1. Contains its own _build.cpp.hpp |
| 497 | 2. Is NOT independently compiled by a build file in src/fl/build/ |
| 498 | |
| 499 | ...must be included. This catches the case where a new subdirectory is added |
| 500 | but not included in _build.cpp.hpp, causing linker errors. |
| 501 | |
| 502 | Returns: |
| 503 | list of violation strings |
| 504 | """ |
| 505 | violations: list[str] = [] |
| 506 | |
| 507 | for build_hpp in src_dir.rglob(BUILD_HPP): |
| 508 | dir_path = build_hpp.parent |
| 509 | content = build_hpp.read_text(encoding="utf-8") |
| 510 | rel_file = build_hpp.relative_to(PROJECT_ROOT).as_posix() |
| 511 | |
| 512 | # Find all immediate subdirs with _build.cpp.hpp |
| 513 | for subdir in sorted(dir_path.iterdir()): |
| 514 | if not subdir.is_dir(): |
| 515 | continue |
| 516 | sub_build = subdir / BUILD_HPP |
| 517 | if not sub_build.exists(): |
| 518 | continue |
| 519 | |
| 520 | # Skip subdirs that are independently compiled by a build file in src/fl/build/ |
| 521 | try: |
| 522 | subdir_rel = subdir.relative_to(src_dir).as_posix() |
| 523 | except ValueError: |
| 524 | continue |
| 525 | if subdir_rel in independently_compiled_dirs: |
| 526 | continue |
| 527 | |
| 528 | # This subdir's _build.cpp.hpp should be included |
| 529 | include_path = sub_build.relative_to(src_dir).as_posix() |
| 530 | if include_path not in content: |
| 531 | violations.append( |
| 532 | f"{rel_file}: Missing subdirectory include '{include_path}'. " |
| 533 | f"All immediate subdirectories with {BUILD_HPP} must be included." |
| 534 | ) |
| 535 | |
| 536 | return violations |
| 537 | |
| 538 | |
| 539 | def _check_alphabetical_order(src_dir: Path) -> list[str]: |
no test coverage detected