Debian Codegraph @

build/clang-plugin/ThirdPartyPaths.py

raw
1 #!/usr/bin/env python3
2
3 import json
4
5
6 def generate(output, *input_paths):
7 """
8 This file generates a ThirdPartyPaths.cpp file from the ThirdPartyPaths.txt
9 file in /tools/rewriting, which is used by the Clang Plugin to help identify
10 sources which should be ignored.
11 """
12 tpp_list = []
13 lines = set()
14
15 for path in input_paths:
16 with open(path) as f:
17 lines.update(f.readlines())
18
19 for line in lines:
20 line = line.strip()
21 if line.endswith("/"):
22 line = line[:-1]
23 tpp_list.append(line)
24 tpp_strings = ",\n ".join([json.dumps(tpp) for tpp in sorted(tpp_list)])
25
26 output.write(
27 """\
28 /* THIS FILE IS GENERATED BY ThirdPartyPaths.py - DO NOT EDIT */
29
30 #include <stdint.h>
31
32 const char* MOZ_THIRD_PARTY_PATHS[] = {
33 %s
34 };
35
36 extern const uint32_t MOZ_THIRD_PARTY_PATHS_COUNT = %d;
37
38 """
39 % (tpp_strings, len(tpp_list))
40 )