From 2dcca1c4d4aeb114601ddab0d14d73f7393fbc27 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Mon, 10 Oct 2016 12:39:00 -0700 Subject: [PATCH] [infer][java] The version of the Java compiler should be part of the target key used by Buck Summary: Infer should always include the version of the Java compiler as part of the target key used by Buck Reviewed By: jvillard Differential Revision: D3989649 fbshipit-source-id: 605ab2f --- infer/lib/python/infer.py | 5 ++++- infer/lib/python/inferlib/jwlib.py | 14 ++++++++++++-- infer/lib/python/inferlib/utils.py | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/infer/lib/python/infer.py b/infer/lib/python/infer.py index ab72c63e1..8d1fa6b61 100755 --- a/infer/lib/python/infer.py +++ b/infer/lib/python/infer.py @@ -181,7 +181,10 @@ def main(): ' '.join(map(utils.decode, sys.argv))) logging.info('Path to infer script %s (%s)', utils.decode(__file__), os.path.realpath(utils.decode(__file__))) - logging.info(analyze.get_infer_version()) + if not args.buck: + # Should not print the Infer version when Infer is run by Buck. + # Buck reads the whole stderr output to compute the target key + logging.info(analyze.get_infer_version()) logging.info('Platform: %s', utils.decode(platform.platform())) def log_getenv(k): diff --git a/infer/lib/python/inferlib/jwlib.py b/infer/lib/python/inferlib/jwlib.py index b54f37d33..3c70297d9 100644 --- a/infer/lib/python/inferlib/jwlib.py +++ b/infer/lib/python/inferlib/jwlib.py @@ -99,6 +99,12 @@ class CompilerCall(object): self.args, self.remaining_args = parser.parse_known_args(arguments) self.verbose_out = None + def get_version(self): + assert self.args.version + return subprocess.check_output( + self.javac_cmd + self.original_arguments, + stderr=subprocess.STDOUT).strip() + def run(self): if self.args.version: return subprocess.call(self.javac_cmd + self.original_arguments) @@ -250,11 +256,15 @@ class AnalyzerWithFrontendWrapper(analyze.AnalyzerWrapper): config.BUCK_INFER_OUT) self.args.infer_out = os.path.abspath(self.args.infer_out) + def compute_buck_key(self): + javac_version = self.javac.get_version() + infer_version = utils.infer_key(self.args.analyzer) + return '/'.join([javac_version, infer_version]) + def start(self): if self.javac.args.version: if self.args.buck: - key = self.args.analyzer - utils.stderr(utils.infer_key(key)) + utils.stderr(self.compute_buck_key()) else: return self.javac.run() else: diff --git a/infer/lib/python/inferlib/utils.py b/infer/lib/python/inferlib/utils.py index cc4cf5e07..ccb372c86 100644 --- a/infer/lib/python/inferlib/utils.py +++ b/infer/lib/python/inferlib/utils.py @@ -125,7 +125,7 @@ def infer_branch(): def infer_key(analyzer): - return os.pathsep.join([analyzer, infer_version()]) + return '/'.join([analyzer, infer_version()]) def run_infer_stats_aggregator(infer_out, buck_out=None):