use supplied javac instead of the one from PATH

Summary:public
When running `infer -- /path/to/javac Hello.java`, use `/path/to/javac` as the
java compiler, not `javac`.

closes #279

Reviewed By: jeremydubreil, martinoluca

Differential Revision: D2943885

fb-gh-sync-id: 970f07b
shipit-source-id: 970f07b
master
Jules Villard 9 years ago committed by facebook-github-bot-7
parent e4a0e9bbf7
commit 88881581b3

@ -154,7 +154,7 @@ def main():
if not os.path.exists(os.path.join(args.infer_out, 'captured')): if not os.path.exists(os.path.join(args.infer_out, 'captured')):
print('There was nothing to analyze, exiting') print('There was nothing to analyze, exiting')
exit(os.EX_USAGE) exit(os.EX_USAGE)
analysis = analyze.Infer(args, []) analysis = analyze.Infer(args)
analysis.analyze_and_report() analysis.analyze_and_report()
analysis.save_stats() analysis.save_stats()

@ -246,13 +246,13 @@ def run_command(cmd, debug_mode, javac_arguments, step, analyzer):
class Infer: class Infer:
def __init__(self, args, javac_args): def __init__(self, args, javac_cmd=None, javac_args=[]):
self.args = args self.args = args
if self.args.analyzer not in config.ANALYZERS: if self.args.analyzer not in config.ANALYZERS:
help_exit('Unknown analysis mode \"{0}\"' help_exit('Unknown analysis mode \"{0}\"'
.format(self.args.analyzer)) .format(self.args.analyzer))
self.javac = jwlib.CompilerCall(javac_args) self.javac = jwlib.CompilerCall(javac_cmd, javac_args)
if not self.javac.args.version: if not self.javac.args.version:
if javac_args is None: if javac_args is None:

@ -17,7 +17,8 @@ MODULE_DESCRIPTION = '''Run analysis of code built with a command like:
javac <options> <source files> javac <options> <source files>
Analysis examples: Analysis examples:
infer -- javac srcfile.java''' infer -- javac srcfile.java
infer -- /path/to/javac srcfile.java'''
def gen_instance(*args): def gen_instance(*args):
@ -30,7 +31,7 @@ create_argparser = util.base_argparser(MODULE_DESCRIPTION, MODULE_NAME)
class JavacCapture: class JavacCapture:
def __init__(self, args, cmd): def __init__(self, args, cmd):
self.analysis = analyze.Infer(args, cmd[1:]) self.analysis = analyze.Infer(args, cmd[0], cmd[1:])
def capture(self): def capture(self):
try: try:

@ -23,6 +23,7 @@ def create_infer_command(args, javac_arguments):
infer_args += ['--analyzer', 'capture'] infer_args += ['--analyzer', 'capture']
return analyze.Infer(analyze.infer_parser.parse_args(infer_args), return analyze.Infer(analyze.infer_parser.parse_args(infer_args),
'javac',
analyze.get_javac_args(['javac'] + javac_arguments)) analyze.get_javac_args(['javac'] + javac_arguments))

@ -42,8 +42,8 @@ class AnnotationProcessorNotFound(Exception):
class CompilerCall: class CompilerCall:
def __init__(self, arguments): def __init__(self, javac_cmd, arguments):
self.javac_cmd = javac_cmd
self.original_arguments = arguments self.original_arguments = arguments
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
@ -51,9 +51,9 @@ class CompilerCall:
def run(self): def run(self):
if self.args.version: if self.args.version:
return subprocess.call(['javac'] + self.original_arguments) return subprocess.call([self.javac_cmd] + self.original_arguments)
else: else:
javac_cmd = ['javac', '-verbose', '-g'] javac_cmd = [self.javac_cmd, '-verbose', '-g']
if self.args.bootclasspath is not None: if self.args.bootclasspath is not None:
javac_cmd += ['-bootclasspath', self.args.bootclasspath] javac_cmd += ['-bootclasspath', self.args.bootclasspath]

Loading…
Cancel
Save