Merge infer-deps files generated by Buck

Summary:public
With this change, all the `infer-deps.txt` files generated by buck for those targets
running with the `#infer` flavor, will be merged into one `infer-deps.txt` located in the
designated output folder.

Reviewed By: jvillard

Differential Revision: D2994397

fb-gh-sync-id: 14d8109
shipit-source-id: 14d8109
master
martinoluca 9 years ago committed by Facebook Github Bot 9
parent 082ca6a90a
commit 44502c1673

@ -59,6 +59,10 @@ def create_argparser(group_name=MODULE_NAME):
group.add_argument('--blacklist-regex',
help='Specify the regex for files to skip during '
'the analysis (requires --use-flavors to work)')
group.add_argument('--merge-deps-files', action='store_true',
help='Merge the infer-deps.txt files generated by Buck '
'during the analysis (requires --use-flavors to '
'work)')
return parser
@ -148,6 +152,16 @@ class BuckAnalyzer:
merged_results_path = os.path.join(self.args.infer_out,
config.JSON_REPORT_FILENAME)
utils.dump_json_to_path(all_results, merged_results_path)
if self.args.merge_deps_files:
infer_deps_to_merge = [
os.path.join(
os.path.dirname(x), config.INFER_BUCK_DEPS_FILENAME)
for x in result_files]
merged_infer_deps_path = os.path.join(
self.args.infer_out,
config.INFER_BUCK_DEPS_FILENAME)
utils.merge_and_dedup_files_into_path(infer_deps_to_merge,
merged_infer_deps_path)
utils.stdout('Results saved in {results_path}'
.format(results_path=merged_results_path))
return os.EX_OK

@ -41,6 +41,7 @@ PROC_STATS_FILENAME = 'proc_stats.json'
CSV_REPORT_FILENAME = 'report.csv'
JSON_REPORT_FILENAME = 'report.json'
INFER_BUCK_DEPS_FILENAME = 'infer-deps.txt'
BUGS_FILENAME = 'bugs.txt'
JAVAC_FILELISTS_FILENAME = 'filelists'

@ -302,6 +302,15 @@ def stderr(s, errors='replace'):
print(encode(s, errors=errors), file=sys.stderr)
def merge_and_dedup_files_into_path(files_to_merge, dest):
lines = set()
for file_to_merge in files_to_merge:
with open(file_to_merge, 'r') as fsrc:
lines |= set(fsrc.readlines())
with open(dest, 'w') as fdest:
fdest.writelines(lines)
class AbsolutePathAction(argparse.Action):
"""Convert a path from relative to absolute in the arg parser"""
def __call__(self, parser, namespace, values, option_string=None):

Loading…
Cancel
Save