| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import argparse |
| 4 |
import subprocess |
| 5 |
import typing as T |
| 6 |
|
| 7 |
def run(args: T.List[str]) -> int: |
| 8 |
parser = argparse.ArgumentParser() |
| 9 |
parser.add_argument('--depfile') |
| 10 |
options, yasm_cmd = parser.parse_known_args(args) |
| 11 |
|
| 12 |
# Compile |
| 13 |
returncode = subprocess.call(yasm_cmd) |
| 14 |
if returncode != 0: |
| 15 |
return returncode |
| 16 |
|
| 17 |
# Capture and write depfile |
| 18 |
ret = subprocess.run(yasm_cmd + ['-M'], capture_output=True) |
| 19 |
if ret.returncode != 0: |
| 20 |
return ret.returncode |
| 21 |
with open(options.depfile, 'wb') as f: |
| 22 |
f.write(ret.stdout) |
| 23 |
|
| 24 |
return 0 |