Run ``meson setup``, with one self-healing retry, then persist markers.
(
*,
cmd: list[str],
source_dir: Path,
build_dir: Path,
env: dict[str, str],
markers: MarkerPaths,
hashes: SourceHashes,
debug: bool,
check: bool,
build_mode: str,
enable_examples: bool,
enable_unit_tests: bool,
use_thin_archives: bool,
compiler: CompilerDetection,
)
| 579 | |
| 580 | |
| 581 | def run_meson_setup_command( |
| 582 | *, |
| 583 | cmd: list[str], |
| 584 | source_dir: Path, |
| 585 | build_dir: Path, |
| 586 | env: dict[str, str], |
| 587 | markers: MarkerPaths, |
| 588 | hashes: SourceHashes, |
| 589 | debug: bool, |
| 590 | check: bool, |
| 591 | build_mode: str, |
| 592 | enable_examples: bool, |
| 593 | enable_unit_tests: bool, |
| 594 | use_thin_archives: bool, |
| 595 | compiler: CompilerDetection, |
| 596 | ) -> bool: |
| 597 | """Run ``meson setup``, with one self-healing retry, then persist markers.""" |
| 598 | print_banner("MESON CONFIGURATION", "⚙️") |
| 599 | |
| 600 | def _run_meson_setup() -> tuple[int, str]: |
| 601 | proc = RunningProcess( |
| 602 | cmd, |
| 603 | cwd=source_dir, |
| 604 | timeout=600, |
| 605 | auto_run=True, |
| 606 | check=False, |
| 607 | env=env, |
| 608 | output_formatter=TimestampFormatter(), |
| 609 | ) |
| 610 | returncode = cast(int, proc.wait(echo=True)) |
| 611 | return returncode, str(proc.stdout) |
| 612 | |
| 613 | def _clear_stale_caches() -> None: |
| 614 | _ts_print("[MESON] 🔄 Clearing stale test metadata caches...") |
| 615 | cache_files = [ |
| 616 | build_dir / "tests" / "test_metadata.cache", |
| 617 | build_dir / "test_list_cache.txt", |
| 618 | markers.source_files, |
| 619 | ] |
| 620 | for cache_file in cache_files: |
| 621 | if cache_file.exists(): |
| 622 | try: |
| 623 | cache_file.unlink() |
| 624 | _ts_print(f"[MESON] Deleted: {cache_file.name}") |
| 625 | except (OSError, IOError) as e: |
| 626 | _ts_print( |
| 627 | f"[MESON] Warning: Could not delete {cache_file.name}: {e}" |
| 628 | ) |
| 629 | |
| 630 | try: |
| 631 | cleanup_stale_meson_lockfile(build_dir) |
| 632 | returncode, stdout = _run_meson_setup() |
| 633 | |
| 634 | if returncode != 0 and "does not exist" in stdout: |
| 635 | _ts_print( |
| 636 | "[MESON] ⚠️ Setup failed due to missing file (stale cache detected)" |
| 637 | ) |
| 638 | _clear_stale_caches() |
no test coverage detected