MythTV  master
build_commdb.py
Go to the documentation of this file.
1 #! /usr/bin/python3
2 
3 from pathlib import Path
4 import json
5 from optparse import OptionParser
6 
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()
12 
13 paths = list(Path("..").glob("**/*.o.json"))
14 if len(paths) < 600:
15  print("Not enough *.o.json files present. Did you remember to")
16  print("clean ccache and do a full build with clang?")
17  exit(1)
18 
19 outlines = []
20 for path in paths:
21  filename = path.as_posix()
22  badnames = ["/external/", "moc_", "dummy.o.json"]
23  if any(bad in filename for bad in badnames):
24  if options.verbose:
25  print("Skipping input file: {0:s}".format(path.as_posix()))
26  continue
27  in_file = open(path, "r")
28  if not in_file:
29  if options.verbose:
30  print("Cannot open input file: {0:s}".format(filename))
31  continue
32 
33  # Read and strip trailing comma
34  rawcontent = in_file.read()
35  content = json.loads(rawcontent[:-2])
36  in_file.close()
37 
38  # Manipulate file names
39  if content["file"].startswith("../") and not content["file"].endswith("Json.cpp"):
40  if options.verbose:
41  print("Skipping input file2: {0:s}".format(filename))
42  continue
43  content["file"] = content["directory"] + "/" + content["file"]
44 
45  # Save the output for this file
46  if options.verbose:
47  print("Including input file: {0:s}".format(path.as_posix()))
48  outlines.append(json.dumps(content, index=4))
49 
50 # Dump out the compdb file
51 out_file = open("../compile_commands.json", "w")
52 print("[\n{0:s}\n]".format(",\n".join(outlines)), file=out_file)
53 out_file.close()
static void print(const QList< uint > &raw_minimas, const QList< uint > &raw_maximas, const QList< float > &minimas, const QList< float > &maximas)