Build profiler binary using test system (supports Docker)
(self)
| 121 | return False |
| 122 | |
| 123 | def build_profiler(self) -> bool: |
| 124 | """Build profiler binary using test system (supports Docker)""" |
| 125 | print(f"Building profiler (mode: {self.build_mode})...") |
| 126 | |
| 127 | # Use test system which properly handles Docker builds |
| 128 | # test.py wraps the Meson build system and supports Docker |
| 129 | cmd = [ |
| 130 | "uv", |
| 131 | "run", |
| 132 | "python", |
| 133 | "test.py", |
| 134 | self.test_name, |
| 135 | "--cpp", |
| 136 | "--build", # Build-only mode |
| 137 | "--build-mode", |
| 138 | self.build_mode, |
| 139 | ] |
| 140 | |
| 141 | if self.use_docker: |
| 142 | cmd.append("--docker") |
| 143 | |
| 144 | try: |
| 145 | # Use RunningProcess to stream output and avoid buffer deadlock |
| 146 | # test.py can produce lots of output (multiple MB), so we must stream |
| 147 | proc = RunningProcess( |
| 148 | cmd, |
| 149 | auto_run=True, |
| 150 | timeout=600, # 10 minute timeout for Docker builds |
| 151 | ) |
| 152 | |
| 153 | # Stream all output to console |
| 154 | while line := proc.get_next_line(timeout=600): |
| 155 | if isinstance(line, EndOfStream): |
| 156 | break |
| 157 | # Print build output in real-time |
| 158 | print(line, end="") |
| 159 | |
| 160 | # Check exit code |
| 161 | exit_code = proc.wait() |
| 162 | if exit_code == 0: |
| 163 | print(f"✓ Built {self.test_name}") |
| 164 | return True |
| 165 | else: |
| 166 | print(f"Error: Build failed with exit code {exit_code}") |
| 167 | return False |
| 168 | |
| 169 | except KeyboardInterrupt as ki: |
| 170 | handle_keyboard_interrupt(ki) |
| 171 | raise |
| 172 | except Exception as e: |
| 173 | print(f"Error building profiler: {e}") |
| 174 | return False |
| 175 | |
| 176 | def get_binary_path(self) -> Path: |
| 177 | """Get path to built profiler binary""" |
no test coverage detected