(cmd, directory)
| 313 | os.makedirs(path) |
| 314 | |
| 315 | def command_output(cmd, directory): |
| 316 | # Runs a command in a directory and returns its standard output stream. |
| 317 | # Captures the standard error stream and prints it an error occurs. |
| 318 | # Raises a RuntimeError if the command fails to launch or otherwise fails. |
| 319 | if VERBOSE: |
| 320 | print('In {d}: {cmd}'.format(d=directory, cmd=cmd)) |
| 321 | |
| 322 | # errors='replace' affects only how the text output is decoded, and indicates that |
| 323 | # 8-bit characters that aren't recognized by the UTF decoder will be replaced with |
| 324 | # an "unknown character" glyph instead of crashing. |
| 325 | result = subprocess.run(cmd, cwd=directory, capture_output=True, text=True, errors='replace') |
| 326 | |
| 327 | if result.returncode != 0: |
| 328 | print(f'{result.stderr}', file=sys.stderr) |
| 329 | raise RuntimeError(f'Failed to run {cmd} in {directory}') |
| 330 | |
| 331 | if VERBOSE: |
| 332 | print(result.stdout) |
| 333 | return result.stdout |
| 334 | |
| 335 | def run_cmake_command(cmake_cmd): |
| 336 | # NOTE: Because CMake is an exectuable that runs executables |
no outgoing calls
no test coverage detected