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

Function detect_example_file_changes

ci/meson/meson_setup_phases.py:508–561  ·  view source on GitHub ↗

Return True when ``examples/`` files have been added/removed/modified.

(source_dir: Path, build_dir: Path)

Source from the content-addressed store, hash-verified

506
507
508def detect_example_file_changes(source_dir: Path, build_dir: Path) -> bool:
509 """Return True when ``examples/`` files have been added/removed/modified."""
510 try:
511 from ci.meson.example_metadata_cache import compute_example_files_hash
512
513 examples_dir = source_dir / "examples"
514 example_cache_file = build_dir / "examples" / "example_metadata.cache"
515
516 if not examples_dir.exists():
517 return False
518
519 skip_example_hash = False
520 if example_cache_file.exists():
521 try:
522 cache_mtime = example_cache_file.stat().st_mtime
523 max_example_dir_mtime = get_max_dir_mtime(examples_dir)
524 if max_example_dir_mtime <= cache_mtime:
525 skip_example_hash = True
526 except OSError:
527 pass
528
529 if skip_example_hash:
530 return False
531
532 current_example_hash = compute_example_files_hash(examples_dir)
533 cached_example_hash = ""
534 if example_cache_file.exists():
535 try:
536 with open(example_cache_file, "r") as f:
537 cache_data = json.load(f)
538 cached_example_hash = cache_data.get("hash", "")
539 except KeyboardInterrupt as ki:
540 handle_keyboard_interrupt(ki)
541 except Exception:
542 cached_example_hash = ""
543
544 if current_example_hash != cached_example_hash:
545 print_warning(
546 "[MESON] ⚠️ Detected example file changes (files added/removed/modified)"
547 )
548 if example_cache_file.exists():
549 try:
550 example_cache_file.unlink()
551 except OSError:
552 pass
553 return True
554 return False
555
556 except KeyboardInterrupt as ki:
557 handle_keyboard_interrupt(ki)
558 raise
559 except Exception as e:
560 _ts_print(f"[MESON] Warning: Could not check example file changes: {e}")
561 return True
562
563
564def check_obsolete_zig_wrappers(source_dir: Path) -> None:

Callers 1

setup_meson_buildFunction · 0.90

Calls 7

get_max_dir_mtimeFunction · 0.90
print_warningFunction · 0.90
unlinkMethod · 0.80
loadMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected