diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index 2245ac2cb..8ca0dcbac 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -173,6 +173,8 @@ infer_group.add_argument('--specs-dir-list-file', 'in to the list of directories to be ' 'searched for spec files') +infer_group.add_argument('--java-jar-compiler', + metavar='') def remove_infer_out(infer_out): # it is safe to ignore errors here because recreating the infer_out diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index bc468947c..319b20cea 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -45,11 +45,11 @@ INFER_JSON_REPORT = os.path.join(config.BUCK_INFER_OUT, INFER_STATS = os.path.join(config.BUCK_INFER_OUT, config.STATS_FILENAME) INFER_SCRIPT = """\ -#!/usr/bin/env {0} +#!/usr/bin/env {python_executable} import subprocess import sys -cmd = {1} + ['--', 'javac'] + sys.argv[1:] +cmd = {infer_command} + ['--', 'javac'] + sys.argv[1:] subprocess.check_call(cmd) """ @@ -64,6 +64,12 @@ def prepare_build(args): '--analyzer', args.analyzer, ] + if args.java_jar_compiler is not None: + infer_options += [ + '--java-jar-compiler', + args.java_jar_compiler, + ] + if args.debug: infer_options.append('--debug') @@ -102,7 +108,9 @@ def prepare_build(args): dir='.') as infer_script: logging.info('Creating %s' % infer_script.name) infer_script.file.write( - utils.encode(INFER_SCRIPT.format(sys.executable, infer_command))) + utils.encode(INFER_SCRIPT.format( + python_executable=sys.executable, + infer_command=infer_command))) st = os.stat(infer_script.name) os.chmod(infer_script.name, st.st_mode | stat.S_IEXEC) diff --git a/infer/lib/python/inferlib/capture/java.py b/infer/lib/python/inferlib/capture/java.py index ac3723313..d1758cbad 100644 --- a/infer/lib/python/inferlib/capture/java.py +++ b/infer/lib/python/inferlib/capture/java.py @@ -45,12 +45,13 @@ def parse_command_line(cmd): class JavaJarCapture: def __init__(self, args, cmd): java_binary, java_jar, other_args = parse_command_line(cmd) + if args.java_jar_compiler is not None: + java_jar = args.java_jar_compiler self.analysis = jwlib.AnalyzerWithJavaJar( args, java_binary, java_jar, - other_args - ) + other_args) def capture(self): try: diff --git a/infer/lib/python/inferlib/capture/javac.py b/infer/lib/python/inferlib/capture/javac.py index 59cb621e5..651637825 100644 --- a/infer/lib/python/inferlib/capture/javac.py +++ b/infer/lib/python/inferlib/capture/javac.py @@ -32,11 +32,17 @@ create_argparser = util.base_argparser(MODULE_DESCRIPTION, MODULE_NAME) class JavacCapture: def __init__(self, args, cmd): - self.analysis = jwlib.AnalyzerWithJavac( - args, - cmd[0], - cmd[1:], - ) + if args.java_jar_compiler is not None: + self.analysis = jwlib.AnalyzerWithJavaJar( + args, + 'java', + args.java_jar_compiler, + cmd[1:]) + else: + self.analysis = jwlib.AnalyzerWithJavac( + args, + cmd[0], + cmd[1:]) def capture(self): try: diff --git a/infer/lib/python/inferlib/jwlib.py b/infer/lib/python/inferlib/jwlib.py index 3c70297d9..5363d047d 100644 --- a/infer/lib/python/inferlib/jwlib.py +++ b/infer/lib/python/inferlib/jwlib.py @@ -33,12 +33,6 @@ parser.add_argument('-bootclasspath', type=utils.decode) parser.add_argument('-d', dest='classes_out', default=current_directory) parser.add_argument('-processorpath', type=utils.decode, dest='processorpath') parser.add_argument('-processor', type=utils.decode, dest='processor') -parser.add_argument('-o', '--out', metavar='', - default=utils.encode(config.DEFAULT_INFER_OUT), - dest='infer_out', - type=utils.decode, - action=utils.AbsolutePathAction, - help='Set the Infer results directory') def _get_javac_args(args): diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 2d87f8b58..e91c09c8d 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -58,8 +58,8 @@ let () = (if not Config.absolute_paths then [] else ["--absolute-paths"]) @ (match Config.analyzer with None -> [] | Some a -> - ["--analyzer"; - IList.assoc (=) a (IList.map (fun (n,a) -> (a,n)) Config.string_to_analyzer)]) @ + ["--analyzer"; + IList.assoc (=) a (IList.map (fun (n,a) -> (a,n)) Config.string_to_analyzer)]) @ (match Config.blacklist with | Some s when in_buck_mode -> ["--blacklist-regex"; s] | _ -> []) @ @@ -67,6 +67,8 @@ let () = ["--android-harness"]) @ (if not Config.buck then [] else ["--buck"]) @ + (match Config.java_jar_compiler with None -> [] | Some p -> + ["--java-jar-compiler"; p]) @ (match IList.rev Config.buck_build_args with | args when in_buck_mode -> IList.map (fun arg -> ["--Xbuck"; "'" ^ arg ^ "'"]) args |> IList.flatten @@ -88,7 +90,7 @@ let () = (if Option.is_none Config.use_compilation_database || not in_buck_mode then [] else ["--use-compilation-database"]) @ (match Config.infer_cache with None -> [] | Some s -> - ["--infer_cache"; s]) @ + ["--infer_cache"; s]) @ "-j" :: (string_of_int Config.jobs) :: "-l" :: (string_of_float Config.load_average) :: (if not Config.pmd_xml then [] else @@ -97,9 +99,9 @@ let () = ["--reactive"]) @ "--out" :: Config.results_dir :: (match Config.project_root with None -> [] | Some pr -> - ["--project_root"; pr]) @ + ["--project_root"; pr]) @ (match Config.xcode_developer_dir with None -> [] | Some d -> - ["--xcode-developer-dir"; d]) @ + ["--xcode-developer-dir"; d]) @ (if Config.rest = [] then [] else ("--" :: build_cmd)) ) in diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 67fcba03a..a0d40998a 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1189,6 +1189,11 @@ and zip_specs_library = CLOpt.mk_string_list ~long:"zip-specs-library" ~short:"ziplib" ~f:resolve ~meta:"zip file" "Search for .spec files in a zip file" +and java_jar_compiler = + CLOpt.mk_string_opt + ~long:"java-jar-compiler" + ~exes:CLOpt.[Java] + ~meta:"path" "Specifify the Java compiler jar used to generate the bytecode" (** Configuration values specified by environment variables *) @@ -1430,6 +1435,7 @@ and frontend_stats = !frontend_stats and headers = !headers and infer_cache = !infer_cache and iterations = !iterations +and java_jar_compiler = !java_jar_compiler and javac_verbose_out = !verbose_out and jobs = !jobs and join_cond = !join_cond diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 0c99734a0..2a7bba59d 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -270,7 +270,7 @@ val write_html : bool val xcode_developer_dir : string option val xml_specs : bool val zip_libraries : zip_library list - +val java_jar_compiler : string option (** Global variables *)