12Parallel find-all-symbols runner
13================================
15Runs find-all-symbols over all files in a compilation database.
18- Run find-all-symbols on all files in the current working directory.
19 run-find-all-symbols.py <source-file>
21Compilation database setup:
22http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
37def find_compilation_database(path):
38 """Adjusts the directory until a compilation database is found."""
40 while not os.path.isfile(os.path.join(result, path)):
41 if os.path.realpath(result) ==
"/":
42 print(
"Error: could not find compilation database.")
45 return os.path.realpath(result)
49 """Merge all symbol files (yaml) in a given directory into a single file."""
50 invocation = [args.binary,
"-merge-dir=" + directory, args.saving_path]
51 subprocess.call(invocation)
52 print(
"Merge is finished. Saving results in " + args.saving_path)
56 """Takes filenames out of queue and runs find-all-symbols on them."""
59 invocation = [args.binary, name,
"-output-dir=" + tmpdir,
"-p=" + build_path]
60 sys.stdout.write(
" ".join(invocation) +
"\n")
61 subprocess.call(invocation)
66 parser = argparse.ArgumentParser(
67 description=
"Runs find-all-symbols over all" "files in a compilation database."
72 default=
"./bin/find-all-symbols",
73 help=
"path to find-all-symbols binary",
76 "-j", type=int, default=0, help=
"number of instances to be run in parallel."
79 "-p", dest=
"build_path", help=
"path used to read a compilation database."
82 "-saving-path", default=
"./find_all_symbols_db.yaml", help=
"result saving path"
84 args = parser.parse_args()
86 db_path =
"compile_commands.json"
88 if args.build_path
is not None:
89 build_path = args.build_path
93 tmpdir = tempfile.mkdtemp()
96 database = json.load(open(os.path.join(build_path, db_path)))
97 files = [entry[
"file"]
for entry
in database]
100 files = [f
for f
in files
if not f.endswith(
".rc")]
104 max_task = multiprocessing.cpu_count()
108 queue = Queue.Queue(max_task)
109 for _
in range(max_task):
110 t = threading.Thread(
111 target=run_find_all_symbols, args=(args, tmpdir, build_path, queue)
125 except KeyboardInterrupt:
128 print(
"\nCtrl-C detected, goodbye.")
132if __name__ ==
"__main__":
def MergeSymbols(directory, args)
def find_compilation_database(path)
def run_find_all_symbols(args, tmpdir, build_path, queue)