1
0
Fork 0

added --dryrun

This commit is contained in:
Christian Kühnel 2020-05-04 14:16:50 +00:00
parent 5fd70b614d
commit b819a22205

View file

@ -18,15 +18,20 @@ import os
import platform
import subprocess
def run_ninja(target: str, repo_path: str):
def run_ninja(target: str, repo_path: str, *, dryrun:bool = False):
build_dir = os.path.join(repo_path, 'build')
cmd = 'ninja {}'.format(target)
subprocess.check_call(cmd, shell=True, cwd=build_dir)
if dryrun:
print('Dryrun. Command would have been:\n{}'.format(cmd))
else:
subprocess.check_call(cmd, shell=True, cwd=build_dir)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run ninja for LLVM.')
parser.add_argument('target')
parser.add_argument('repo_path', type=str, nargs='?', default=os.getcwd())
parser.add_argument('--dryrun', action='store_true')
args = parser.parse_args()
run_ninja(args.target, args.repo_path)
run_ninja(args.target, args.repo_path, dryrun=args.dryrun)