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')):
print('There was nothing to analyze, exiting')
exit(os.EX_USAGE)
analysis = analyze.Infer(args, [])
analysis = analyze.Infer(args)
analysis.analyze_and_report()
analysis.save_stats()

@ -246,13 +246,13 @@ def run_command(cmd, debug_mode, javac_arguments, step, analyzer):
class Infer:
def __init__(self, args, javac_args):
def __init__(self, args, javac_cmd=None, javac_args=[]):
self.args = args
if self.args.analyzer not in config.ANALYZERS:
help_exit('Unknown analysis mode \"{0}\"'
.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 javac_args is None:

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

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

@ -42,8 +42,8 @@ class AnnotationProcessorNotFound(Exception):
class CompilerCall:
def __init__(self, arguments):
def __init__(self, javac_cmd, arguments):
self.javac_cmd = javac_cmd
self.original_arguments = arguments
self.args, self.remaining_args = parser.parse_known_args(arguments)
self.verbose_out = None
@ -51,9 +51,9 @@ class CompilerCall:
def run(self):
if self.args.version:
return subprocess.call(['javac'] + self.original_arguments)
return subprocess.call([self.javac_cmd] + self.original_arguments)
else:
javac_cmd = ['javac', '-verbose', '-g']
javac_cmd = [self.javac_cmd, '-verbose', '-g']
if self.args.bootclasspath is not None:
javac_cmd += ['-bootclasspath', self.args.bootclasspath]

Loading…
Cancel
Save