aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/clang_tidy_arch.py
blob: 7caf623a3d8e55b109356816293faf2c4021ec5d (plain) (blame)
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
import os
import argparse
import json


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--output-file")
    parser.add_argument("--build-root")
    parser.add_argument("--source-root")
    return parser.parse_known_args()


def main():
    args, unknown_args = parse_args()
    inputs = unknown_args
    result_json = {}
    for inp in inputs:
        if os.path.exists(inp) and inp.endswith("tidyjson"):
            with open(inp, 'r') as afile:
                file_content = afile.read().strip()
                if not file_content:
                    continue
                errors = json.loads(file_content)
            testing_src = errors["file"]
            result_json[testing_src] = errors

    with open(args.output_file, 'w') as afile:
        json.dump(result_json, afile, indent=4)  # TODO remove indent


if __name__ == "__main__":
    main()