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

Function compile_pch

ci/wasm_compile_pch.py:296–387  ·  view source on GitHub ↗

Compile the PCH file. Args: emcc: Compiler command (e.g., 'clang-tool-chain-emcc') flags: Compilation flags from TOML verbose: Enable verbose output Returns: Exit code (0 = success)

(
    emcc: str,
    flags: dict[str, list[str]],
    verbose: bool = False,
)

Source from the content-addressed store, hash-verified

294
295
296def compile_pch(
297 emcc: str,
298 flags: dict[str, list[str]],
299 verbose: bool = False,
300) -> int:
301 """
302 Compile the PCH file.
303
304 Args:
305 emcc: Compiler command (e.g., 'clang-tool-chain-emcc')
306 flags: Compilation flags from TOML
307 verbose: Enable verbose output
308
309 Returns:
310 Exit code (0 = success)
311 """
312 print(f"Compiling PCH: {PCH_HEADER.name} -> {PCH_OUTPUT.name}...")
313
314 # Ensure build directory exists
315 BUILD_DIR.mkdir(parents=True, exist_ok=True)
316
317 # Build includes (must match regular compilation)
318 includes = [
319 f"-I{PROJECT_ROOT / 'src'}",
320 f"-I{PROJECT_ROOT / 'src' / 'platforms' / 'wasm'}",
321 f"-I{PROJECT_ROOT / 'src' / 'platforms' / 'wasm' / 'compiler'}",
322 ]
323
324 # PCH validation flags (catch invalidation/corruption issues)
325 pch_validation_flags = [
326 "-Werror=invalid-pch", # Treat invalid PCH as hard error
327 "-verify-pch", # Load and verify PCH is not stale
328 "-fpch-validate-input-files-content", # Validate based on content, not mtime
329 "-fpch-instantiate-templates", # Instantiate templates during PCH build
330 ]
331
332 # Build command using compile_pch.py wrapper (fixes depfile)
333 cmd = (
334 [
335 "uv",
336 "run",
337 "python",
338 str(PROJECT_ROOT / "ci" / "compile_pch.py"),
339 emcc,
340 "-x",
341 "c++-header", # Treat input as C++ header
342 str(PCH_HEADER), # Input: wasm_pch.h
343 "-o",
344 str(PCH_OUTPUT), # Output: wasm_pch.h.pch
345 "-MD",
346 "-MF",
347 str(PCH_DEPFILE), # Generate dependency file
348 ]
349 + includes
350 + flags["defines"]
351 + flags["compiler_flags"]
352 + pch_validation_flags
353 )

Callers 1

mainFunction · 0.85

Calls 6

compute_content_hashFunction · 0.70
compute_flags_hashFunction · 0.70
get_compiler_versionFunction · 0.70
save_metadataFunction · 0.70
printFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected