1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/env python3
import subprocess
import argparse
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():
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")]
+ [
t
for t in get_targets_of_rule(args.build_root, "CUSTOM_COMMAND_DEP")
if t.endswith(".capnp.h")
]
+ [
t
for t in get_targets_of_rule(args.build_root, "CUSTOM_COMMAND")
if t.endswith(".gen.inc")
]
)
ninja_build(args.build_root, targets)
if __name__ == "__main__":
main()
|