aboutsummaryrefslogtreecommitdiff
path: root/meson/clang-tidy/build_required_targets.py
blob: 5c0e9641e64e3c5fbdf5358c3a56f7a04b29e540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3
import subprocess

def get_targets_of_rule(build_root: str, rule_name: str) -> list[str]:
    return subprocess.check_output(['ninja', '-C', build_root, '-t', 'targets', 'rule', rule_name]).decode().strip().splitlines()

def ninja_build(build_root: str, targets: list[str]):
    subprocess.check_call(['ninja', '-C', build_root, '--', *targets])

def main():
    import argparse
    ap = argparse.ArgumentParser(description='Builds required targets for clang-tidy')
    ap.add_argument('build_root', help='Ninja build root', type=str)

    args = ap.parse_args()

    targets = [t for t in get_targets_of_rule(args.build_root, 'CUSTOM_COMMAND') if t.endswith('gen.hh')]
    ninja_build(args.build_root, targets)

if __name__ == '__main__':
    main()