Resolve the venv zccache binary IF it supports `meson configure`. Returns a ``ZccacheCapability`` only when the binary is found and is recent enough to ship the configure-cache wrapper (zccache 1.11.12+, zackees/zccache#649). Returns ``None`` otherwise so the caller falls back to a
()
| 371 | |
| 372 | |
| 373 | def _get_zccache_meson_configure_path() -> Optional[ZccacheCapability]: |
| 374 | """Resolve the venv zccache binary IF it supports `meson configure`. |
| 375 | |
| 376 | Returns a ``ZccacheCapability`` only when the binary is found and is |
| 377 | recent enough to ship the configure-cache wrapper (zccache 1.11.12+, |
| 378 | zackees/zccache#649). Returns ``None`` otherwise so the caller falls |
| 379 | back to a plain ``meson setup`` invocation. |
| 380 | |
| 381 | Detection is intentionally cheap: we don't parse the version string — |
| 382 | instead we read ``zccache meson configure --help`` and look for the |
| 383 | wrapper's docstring (any wrapper-equipped binary) plus the ``--no-walk`` |
| 384 | flag name (1.11.14+). That sidesteps the upgrade window where the |
| 385 | binary is installed but predates a flag we want to use. |
| 386 | """ |
| 387 | script_dir = Path(__file__).resolve().parent |
| 388 | project_root = script_dir.parent.parent |
| 389 | is_windows = sys.platform.startswith("win") or os.name == "nt" |
| 390 | venv_zccache = ( |
| 391 | project_root |
| 392 | / ".venv" |
| 393 | / "Scripts" |
| 394 | / ("zccache.exe" if is_windows else "zccache") |
| 395 | ) |
| 396 | if not venv_zccache.exists(): |
| 397 | return None |
| 398 | try: |
| 399 | # Cheap probe: ask zccache to describe its meson configure subcommand. |
| 400 | # The wrapper-equipped binary prints "Cache-aware `meson setup`..." at |
| 401 | # the top; a passthrough binary forwards to real meson which prints |
| 402 | # "usage: meson [-h]..." instead. |
| 403 | result = subprocess.run( |
| 404 | [str(venv_zccache), "meson", "configure", "--help"], |
| 405 | capture_output=True, |
| 406 | text=True, |
| 407 | timeout=10, |
| 408 | check=False, |
| 409 | ) |
| 410 | except KeyboardInterrupt as ki: |
| 411 | handle_keyboard_interrupt(ki) |
| 412 | raise ki |
| 413 | except (subprocess.SubprocessError, OSError): |
| 414 | return None |
| 415 | if "Cache-aware" not in result.stdout: |
| 416 | return None |
| 417 | return ZccacheCapability( |
| 418 | path=venv_zccache, |
| 419 | supports_no_walk="--no-walk" in result.stdout, |
| 420 | ) |
| 421 | |
| 422 | |
| 423 | def _write_zccache_input_sidecar( |
no test coverage detected