MythTV  master
build_compdb.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  if len(rawcontent) < 2:
36  print("Bad file contents: {0:s}".format(filename))
37  exit(1)
38  content = json.loads(rawcontent[:-2])
39  in_file.close()
40 
41  # Manipulate file names
42  if content["file"].startswith("../") and not content["file"].endswith("Json.cpp"):
43  if options.verbose:
44  print("Skipping input file2: {0:s}".format(filename))
45  continue
46  content["file"] = content["directory"] + "/" + content["file"]
47 
48  # Save the output for this file
49  if options.verbose:
50  print("Including input file: {0:s}".format(path.as_posix()))
51  outlines.append(json.dumps(content, indent=4))
52 
53 # Dump out the compdb file
54 out_file = open("../compile_commands.json", "w")
55 print("[\n{0:s}\n]".format(",\n".join(outlines)), file=out_file)
56 out_file.close()
print
static void print(const QList< uint > &raw_minimas, const QList< uint > &raw_maximas, const QList< float > &minimas, const QList< float > &maximas)
Definition: vbi608extractor.cpp:29