3 from pathlib
import Path
5 from optparse
import OptionParser
7 parser = OptionParser()
8 parser.add_option(
"-v",
"--verbose",
9 action=
"store_true", dest=
"verbose",
10 help=
"Print progress messages")
11 (options, args) = parser.parse_args()
13 paths = list(Path(
"..").glob(
"**/*.o.json"))
15 print(
"Not enough *.o.json files present. Did you remember to")
16 print(
"clean ccache and do a full build with clang?")
21 filename = path.as_posix()
22 badnames = [
"/external/",
"moc_",
"dummy.o.json"]
23 if any(bad
in filename
for bad
in badnames):
25 print(
"Skipping input file: {0:s}".format(path.as_posix()))
27 in_file = open(path,
"r")
30 print(
"Cannot open input file: {0:s}".format(filename))
34 rawcontent = in_file.read()
35 if len(rawcontent) < 2:
36 print(
"Bad file contents: {0:s}".format(filename))
38 content = json.loads(rawcontent[:-2])
42 if content[
"file"].startswith(
"../")
and not content[
"file"].endswith(
"Json.cpp"):
44 print(
"Skipping input file2: {0:s}".format(filename))
46 content[
"file"] = content[
"directory"] +
"/" + content[
"file"]
50 print(
"Including input file: {0:s}".format(path.as_posix()))
51 outlines.append(json.dumps(content, indent=4))
54 out_file = open(
"../compile_commands.json",
"w")
55 print(
"[\n{0:s}\n]".format(
",\n".join(outlines)), file=out_file)