Detect clang-tool-chain wrappers + zccache + version strings. Caches the compiler and zccache version strings via marker mtimes so we skip the ~3.6s subprocess unless the binary itself has changed.
(markers: MarkerPaths, verbose: bool)
| 51 | |
| 52 | |
| 53 | def detect_compiler_and_cache(markers: MarkerPaths, verbose: bool) -> CompilerDetection: |
| 54 | """Detect clang-tool-chain wrappers + zccache + version strings. |
| 55 | |
| 56 | Caches the compiler and zccache version strings via marker mtimes so we |
| 57 | skip the ~3.6s subprocess unless the binary itself has changed. |
| 58 | """ |
| 59 | in_docker = os.environ.get("FASTLED_DOCKER", "0") == "1" |
| 60 | |
| 61 | cache_binary: Optional[str] = None |
| 62 | cache_name: Optional[str] = None |
| 63 | if not in_docker: |
| 64 | zccache_binary = _find_zccache_binary() |
| 65 | if zccache_binary: |
| 66 | cache_binary = zccache_binary |
| 67 | cache_name = "zccache" |
| 68 | else: |
| 69 | _ts_print( |
| 70 | "[MESON] zccache not found, compilation will proceed without caching. To install, run: bash ./install" |
| 71 | ) |
| 72 | else: |
| 73 | _ts_print("[MESON] Skipping compiler cache in Docker (startup delay too long)") |
| 74 | |
| 75 | clang_wrapper = shutil.which("clang-tool-chain-c") |
| 76 | clangxx_wrapper = shutil.which("clang-tool-chain-cpp") |
| 77 | llvm_ar_wrapper = shutil.which("clang-tool-chain-ar") |
| 78 | |
| 79 | if not clang_wrapper or not clangxx_wrapper or not llvm_ar_wrapper: |
| 80 | _ts_print("[MESON] ERROR: clang-tool-chain wrapper commands not found in PATH") |
| 81 | _ts_print( |
| 82 | "[MESON] Install clang-tool-chain with: uv pip install clang-tool-chain" |
| 83 | ) |
| 84 | _ts_print("[MESON] Missing commands:") |
| 85 | if not clang_wrapper: |
| 86 | _ts_print("[MESON] - clang-tool-chain-c") |
| 87 | if not clangxx_wrapper: |
| 88 | _ts_print("[MESON] - clang-tool-chain-cpp") |
| 89 | if not llvm_ar_wrapper: |
| 90 | _ts_print("[MESON] - clang-tool-chain-ar") |
| 91 | raise RuntimeError("clang-tool-chain wrapper commands not available") |
| 92 | |
| 93 | current_compiler_version = "" |
| 94 | version_from_cache = False |
| 95 | clangxx_path = Path(clangxx_wrapper) |
| 96 | if markers.compiler_version.exists() and clangxx_path.exists(): |
| 97 | try: |
| 98 | compiler_mtime = clangxx_path.stat().st_mtime |
| 99 | marker_mtime = markers.compiler_version.stat().st_mtime |
| 100 | if compiler_mtime < marker_mtime: |
| 101 | cached_ver = markers.compiler_version.read_text( |
| 102 | encoding="utf-8" |
| 103 | ).strip() |
| 104 | if cached_ver and cached_ver != "unknown": |
| 105 | current_compiler_version = cached_ver |
| 106 | version_from_cache = True |
| 107 | except OSError: |
| 108 | pass |
| 109 | if not version_from_cache: |
| 110 | fast_compiler = _resolve_fast_compiler_binary() |
no test coverage detected