Source code

Revision control

Other Tools

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 tpp_list])
25
26
output.write("""\
27
/* THIS FILE IS GENERATED BY ThirdPartyPaths.py - DO NOT EDIT */
28
29
#include <stdint.h>
30
31
const char* MOZ_THIRD_PARTY_PATHS[] = {
32
%s
33
};
34
35
extern const uint32_t MOZ_THIRD_PARTY_PATHS_COUNT = %d;
36
37
""" % (tpp_strings, len(tpp_list)))