Bug 1776444 [wpt PR 34582] - Revert "Add TimedHTMLParserBudget to fieldtrial_testing_...
[gecko.git] / build / clang-plugin / ThirdPartyPaths.py
blobbd9d236974052ce121a5c6192857c6720f6aa0b9
1 #!/usr/bin/env python3
3 import glob
4 import json
5 import sys
7 # Import buildconfig if available, otherwise set has_buildconfig to False so
8 # we skip the check which relies on it.
9 try:
10 import buildconfig
11 except ImportError:
12 has_buildconfig = False
13 else:
14 has_buildconfig = True
17 def generate(output, *input_paths):
18 """
19 This file generates a ThirdPartyPaths.cpp file from the ThirdPartyPaths.txt
20 file in /tools/rewriting, which is used by the Clang Plugin to help identify
21 sources which should be ignored.
22 """
23 tpp_list = []
24 lines = set()
25 path_found = True
27 for path in input_paths:
28 with open(path) as f:
29 lines.update(f.readlines())
31 for line in lines:
32 line = line.strip()
33 if line.endswith("/"):
34 line = line[:-1]
36 if has_buildconfig:
37 # Ignore lines starting with $UNVALIDATED
38 # These should only be coming from Unvalidated.txt
39 if line.startswith("$UNVALIDATED"):
40 line = line[13:]
41 elif not glob.glob(buildconfig.topsrcdir + "/" + line):
42 path_found = False
44 if path_found:
45 tpp_list.append(line)
46 else:
47 print(
48 "Third-party path "
49 + line
50 + " does not exist. Remove it from Generated.txt or "
51 + "ThirdPartyPaths.txt and try again."
53 sys.exit(1)
54 tpp_strings = ",\n ".join([json.dumps(tpp) for tpp in sorted(tpp_list)])
56 output.write(
57 """\
58 /* THIS FILE IS GENERATED BY ThirdPartyPaths.py - DO NOT EDIT */
60 #include <stdint.h>
62 const char* MOZ_THIRD_PARTY_PATHS[] = {
66 extern const uint32_t MOZ_THIRD_PARTY_PATHS_COUNT = %d;
68 """
69 % (tpp_strings, len(tpp_list))