From 208021fc7e8a8a15d0a23327c4ba6d5ca2b52372 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Tue, 9 Feb 2016 08:07:15 -0800 Subject: [PATCH] Fix the buck integration for the analysis of Buck itself Summary: public The analysis of the Buck project was failing because this script converts the aliases into their expanded target names. It turns out that for Buck, the name of the command is `buck` and the name of the alias is also `buck`, which led to conflicts. This is now fixed by only replacing the targets in the part of the command line that is after `build` in `buck build ...` Reviewed By: sblackshear Differential Revision: D2914446 fb-gh-sync-id: ddce4ed shipit-source-id: ddce4ed --- infer/lib/python/inferlib/bucklib.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index 7ae04cddd..c64f88277 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -441,8 +441,13 @@ def parse_buck_command(args): build_keyword = 'build' if build_keyword in args and len(args[args.index(build_keyword):]) > 1: next_index = args.index(build_keyword) + 1 - buck_args = parser.parse_args(args[next_index:]) - return buck_args + buck_args = args[next_index:] + parsed_args = parser.parse_args(buck_args) + base_cmd_without_targets = [p for p in buck_args + if p not in parsed_args.targets] + base_cmd = ['buck', build_keyword] + base_cmd_without_targets + return base_cmd, parsed_args + else: raise UnsuportedBuckCommand(args) @@ -452,14 +457,12 @@ class Wrapper: def __init__(self, infer_args, buck_cmd): self.timer = utils.Timer(logging.info) self.infer_args = infer_args - buck_args = parse_buck_command(buck_cmd) self.timer.start('Computing library targets') - buck_cmd_without_targets = [p for p in buck_cmd - if p not in buck_args.targets] + base_cmd, buck_args = parse_buck_command(buck_cmd) self.normalized_targets = get_normalized_targets( buck_args.targets, self.infer_args.verbose) - self.buck_cmd = buck_cmd_without_targets + self.normalized_targets + self.buck_cmd = base_cmd + self.normalized_targets self.timer.stop('%d targets computed', len(self.normalized_targets)) def run(self):