| 45 | self.folders.build.mkdir(parents=True) |
| 46 | |
| 47 | def run_cmd( |
| 48 | self, cmd: tc_build.utils.ValidCmd, capture_output: bool = False, cwd: Path | None = None |
| 49 | ) -> subprocess.CompletedProcess: |
| 50 | if self.show_commands: |
| 51 | # Acts sort of like 'set -x' in bash |
| 52 | print(f"$ {' '.join([shlex.quote(str(elem)) for elem in cmd])}", flush=True) |
| 53 | try: |
| 54 | return subprocess.run( |
| 55 | cmd, capture_output=capture_output, check=True, cwd=cwd, text=True |
| 56 | ) |
| 57 | except subprocess.CalledProcessError as err: |
| 58 | if capture_output: |
| 59 | if err.stdout: |
| 60 | print(err.stdout) |
| 61 | if err.stderr: |
| 62 | print(err.stderr) |
| 63 | raise |