Complete Meson build and test workflow. Args: source_dir: Project root directory build_dir: Build output directory (will be modified to be mode-specific) test_name: Specific test to run (without test_ prefix, e.g., "json") clean: Clean build directory before
(
source_dir: Path,
build_dir: Path,
test_name: Optional[str] = None,
clean: bool = False,
verbose: bool = False,
debug: bool = False,
build_mode: Optional[str] = None,
check: bool = False,
exclude_suites: Optional[list[str]] = None,
test_file_filter: Optional[str] = None,
log_failures: Optional[Path] = None,
)
| 102 | |
| 103 | |
| 104 | def run_meson_build_and_test( |
| 105 | source_dir: Path, |
| 106 | build_dir: Path, |
| 107 | test_name: Optional[str] = None, |
| 108 | clean: bool = False, |
| 109 | verbose: bool = False, |
| 110 | debug: bool = False, |
| 111 | build_mode: Optional[str] = None, |
| 112 | check: bool = False, |
| 113 | exclude_suites: Optional[list[str]] = None, |
| 114 | test_file_filter: Optional[str] = None, |
| 115 | log_failures: Optional[Path] = None, |
| 116 | ) -> MesonTestResult: |
| 117 | """ |
| 118 | Complete Meson build and test workflow. |
| 119 | |
| 120 | Args: |
| 121 | source_dir: Project root directory |
| 122 | build_dir: Build output directory (will be modified to be mode-specific) |
| 123 | test_name: Specific test to run (without test_ prefix, e.g., "json") |
| 124 | clean: Clean build directory before setup |
| 125 | verbose: Enable verbose output |
| 126 | debug: Enable debug mode with full symbols and sanitizers (default: False) |
| 127 | build_mode: Build mode override ("quick", "debug", "release"). If None, uses debug parameter. |
| 128 | check: Enable IWYU static analysis (default: False) |
| 129 | exclude_suites: Optional list of test suites to exclude (e.g., ['examples']) |
| 130 | test_file_filter: Optional .hpp filename to filter test execution (e.g., "backbeat.hpp") |
| 131 | log_failures: Optional directory to write per-test failure logs (<name>_compile.log, <name>_run.log) |
| 132 | |
| 133 | Returns: |
| 134 | MesonTestResult with success status, duration, and test counts |
| 135 | """ |
| 136 | start_time = time.time() |
| 137 | build_timer = BuildTimer() |
| 138 | build_timer.start() |
| 139 | |
| 140 | if build_mode is None: |
| 141 | build_mode = "debug" if debug else "quick" |
| 142 | |
| 143 | if build_mode not in ["quick", "debug", "release", "profile"]: |
| 144 | _ts_print( |
| 145 | f"[MESON] Error: Invalid build_mode '{build_mode}'. Must be 'quick', 'debug', 'release', or 'profile'", |
| 146 | file=sys.stderr, |
| 147 | ) |
| 148 | return MesonTestResult( |
| 149 | success=False, |
| 150 | duration=time.time() - start_time, |
| 151 | num_tests_run=0, |
| 152 | num_tests_passed=0, |
| 153 | num_tests_failed=0, |
| 154 | ) |
| 155 | |
| 156 | # Mode-specific build dir lets libfastled.a cache per mode when source is |
| 157 | # unchanged but compiler flags differ (e.g. .build/meson-quick vs ...-debug). |
| 158 | build_dir = build_dir.parent / f"{build_dir.name}-{build_mode}" |
| 159 | |
| 160 | if not check_meson_installed(): |
| 161 | _ts_print("[MESON] Error: Meson build system is not installed", file=sys.stderr) |