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

Function _recover_stale_build

ci/meson/runner_helpers.py:76–189  ·  view source on GitHub ↗

Attempt to recover from a stale build state. This is called when compilation fails due to missing/renamed/deleted files. It cleans stale Ninja deps, clears metadata caches, and forces Meson reconfiguration so the next compilation attempt has a fresh build graph. Args:

(
    source_dir: Path,
    build_dir: Path,
    debug: bool,
    check: bool,
    build_mode: str,
    verbose: bool,
    enable_examples: bool = True,
)

Source from the content-addressed store, hash-verified

74
75
76def _recover_stale_build(
77 source_dir: Path,
78 build_dir: Path,
79 debug: bool,
80 check: bool,
81 build_mode: str,
82 verbose: bool,
83 enable_examples: bool = True,
84) -> bool:
85 """
86 Attempt to recover from a stale build state.
87
88 This is called when compilation fails due to missing/renamed/deleted files.
89 It cleans stale Ninja deps, clears metadata caches, and forces Meson
90 reconfiguration so the next compilation attempt has a fresh build graph.
91
92 Args:
93 source_dir: Project root directory
94 build_dir: Meson build directory
95 debug: Debug mode flag
96 check: IWYU check flag
97 build_mode: Build mode string
98 verbose: Verbose output flag
99
100 Returns:
101 True if recovery setup succeeded (caller should retry compilation),
102 False if recovery failed
103 """
104 _ts_print("=" * 80)
105 _ts_print("[MESON] 🔧 SELF-HEALING: Stale build state detected - auto-recovering")
106 _ts_print("=" * 80)
107 _ts_print("[MESON] This typically happens when files are renamed or deleted.")
108 _ts_print("[MESON] Cleaning stale dependencies and reconfiguring...")
109
110 try:
111 # Step 1: Clean stale ninja deps using ninja -t cleandead
112 ninja_exe = shutil.which("ninja") or str(
113 Path(sys.prefix) / "Scripts" / "ninja.EXE"
114 )
115 try:
116 result = subprocess.run(
117 [ninja_exe, "-C", str(build_dir), "-t", "cleandead"],
118 capture_output=True,
119 text=True,
120 timeout=60,
121 )
122 if result.returncode == 0:
123 _ts_print(
124 f"[MESON] 🗑️ Cleaned stale Ninja outputs: {result.stdout.strip()}"
125 )
126 except KeyboardInterrupt as ki:
127 handle_keyboard_interrupt(ki)
128 raise
129 except Exception as e:
130 _ts_print(f"[MESON] Warning: ninja cleandead failed: {e}")
131
132 # Step 2: Delete .ninja_deps to force full dependency re-scan
133 ninja_deps = build_dir / ".ninja_deps"

Callers 1

run_streaming_pathFunction · 0.90

Calls 5

setup_meson_buildFunction · 0.90
cleanup_build_artifactsFunction · 0.85
unlinkMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected