13 Parallel find-all-symbols runner 14 ================================ 16 Runs find-all-symbols over all files in a compilation database. 19 - Run find-all-symbols on all files in the current working directory. 20 run-find-all-symbols.py <source-file> 22 Compilation database setup: 23 http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html 28 import multiprocessing
39 """Adjusts the directory until a compilation database is found.""" 41 while not os.path.isfile(os.path.join(result, path)):
42 if os.path.realpath(result) ==
'/':
43 print 'Error: could not find compilation database.' 46 return os.path.realpath(result)
50 """Merge all symbol files (yaml) in a given directaory into a single file.""" 51 invocation = [args.binary,
'-merge-dir='+directory, args.saving_path]
52 subprocess.call(invocation)
53 print 'Merge is finished. Saving results in ' + args.saving_path
57 """Takes filenames out of queue and runs find-all-symbols on them.""" 60 invocation = [args.binary, name,
'-output-dir='+tmpdir,
'-p='+build_path]
61 sys.stdout.write(
' '.
join(invocation) +
'\n')
62 subprocess.call(invocation)
67 parser = argparse.ArgumentParser(description=
'Runs find-all-symbols over all' 68 'files in a compilation database.')
69 parser.add_argument(
'-binary', metavar=
'PATH',
70 default=
'./bin/find-all-symbols',
71 help=
'path to find-all-symbols binary')
72 parser.add_argument(
'-j', type=int, default=0,
73 help=
'number of instances to be run in parallel.')
74 parser.add_argument(
'-p', dest=
'build_path',
75 help=
'path used to read a compilation database.')
76 parser.add_argument(
'-saving-path', default=
'./find_all_symbols_db.yaml',
77 help=
'result saving path')
78 args = parser.parse_args()
80 db_path =
'compile_commands.json' 82 if args.build_path
is not None:
83 build_path = args.build_path
87 tmpdir = tempfile.mkdtemp()
90 database = json.load(open(os.path.join(build_path, db_path)))
91 files = [entry[
'file']
for entry
in database]
95 max_task = multiprocessing.cpu_count()
99 queue = Queue.Queue(max_task)
100 for _
in range(max_task):
101 t = threading.Thread(target=run_find_all_symbols,
102 args=(args, tmpdir, build_path, queue))
116 except KeyboardInterrupt:
119 print '\nCtrl-C detected, goodbye.' 123 if __name__ ==
'__main__':
def find_compilation_database(path)
def run_find_all_symbols(args, tmpdir, build_path, queue)
def MergeSymbols(directory, args)
static std::string join(ArrayRef< SpecialMemberFunctionsCheck::SpecialMemberFunctionKind > SMFS, llvm::StringRef AndOr)