[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
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 61f532d2f8
commit 2dcca1c4d4

@ -181,6 +181,9 @@ def main():
' '.join(map(utils.decode, sys.argv))) ' '.join(map(utils.decode, sys.argv)))
logging.info('Path to infer script %s (%s)', utils.decode(__file__), logging.info('Path to infer script %s (%s)', utils.decode(__file__),
os.path.realpath(utils.decode(__file__))) os.path.realpath(utils.decode(__file__)))
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(analyze.get_infer_version())
logging.info('Platform: %s', utils.decode(platform.platform())) logging.info('Platform: %s', utils.decode(platform.platform()))

@ -99,6 +99,12 @@ class CompilerCall(object):
self.args, self.remaining_args = parser.parse_known_args(arguments) self.args, self.remaining_args = parser.parse_known_args(arguments)
self.verbose_out = None 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): def run(self):
if self.args.version: if self.args.version:
return subprocess.call(self.javac_cmd + self.original_arguments) return subprocess.call(self.javac_cmd + self.original_arguments)
@ -250,11 +256,15 @@ class AnalyzerWithFrontendWrapper(analyze.AnalyzerWrapper):
config.BUCK_INFER_OUT) config.BUCK_INFER_OUT)
self.args.infer_out = os.path.abspath(self.args.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): def start(self):
if self.javac.args.version: if self.javac.args.version:
if self.args.buck: if self.args.buck:
key = self.args.analyzer utils.stderr(self.compute_buck_key())
utils.stderr(utils.infer_key(key))
else: else:
return self.javac.run() return self.javac.run()
else: else:

@ -125,7 +125,7 @@ def infer_branch():
def infer_key(analyzer): 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): def run_infer_stats_aggregator(infer_out, buck_out=None):

Loading…
Cancel
Save