MCPcopy Create free account
hub / github.com/FastLED/FastLED / _check_subdir_completeness

Function _check_subdir_completeness

ci/lint_cpp/test_unity_build.py:489–536  ·  view source on GitHub ↗

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]
)

Source from the content-addressed store, hash-verified

487
488
489def _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
539def _check_alphabetical_order(src_dir: Path) -> list[str]:

Callers 1

check_scanned_dataFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected