diff --git a/infer/src/Makefile b/infer/src/Makefile index 95900040a..a907c0eb2 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -35,7 +35,7 @@ OCAMLBUILD_OPTIONS = \ -tag-line "<*{clang/clang_ast_*,backend/jsonbug_*,checkers/stacktree_*}>: warn(-27-32-35-39)" \ -tag-line "<*/{,*/}*.{ml,re}{,i}>: package(ppx_compare)" \ -tag thread \ - -pkgs atdgen,core,ctypes.foreign,oUnit,str,unix,xmlm,yojson,zip + -pkgs atdgen,core,ctypes.foreign,extlib,oUnit,str,unix,xmlm,yojson,zip ifeq ($(ENABLE_OCAML_BINANNOT),yes) OCAMLBUILD_OPTIONS += -cflags -bin-annot diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index a1bbad73c..bd72ed483 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -204,7 +204,7 @@ let capture = function capture_with_compilation_database json_cdb | BuckGenrule path -> L.stdout "Capturing for Buck genrule compatibility...@\n"; - JMain.main (lazy (JClasspath.load_from_arguments path)) + JMain.from_arguments path | ClangCompilationDB db_files -> L.stdout "Capturing using compilation database...@\n"; capture_with_compilation_database db_files diff --git a/infer/src/integration/Javac.ml b/infer/src/integration/Javac.ml index 043e5e57c..299080c6d 100644 --- a/infer/src/integration/Javac.ml +++ b/infer/src/integration/Javac.ml @@ -82,5 +82,5 @@ let compile compiler build_prog build_args = let capture compiler ~prog ~args = let verbose_out_file = compile compiler prog args in if Config.analyzer <> Config.Compile then - JMain.main (lazy (JClasspath.load_from_verbose_output verbose_out_file)) ; + JMain.from_verbose_out verbose_out_file; if not (Config.debug_mode || Config.stats_mode) then Unix.unlink verbose_out_file diff --git a/infer/src/java/jMain.ml b/infer/src/java/jMain.ml index 65682c41c..c6678776c 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -139,7 +139,6 @@ let do_all_files classpath sources classes = JClasspath.cleanup program; L.out_debug "done @." - (* loads the source files and translates them *) let main load_sources_and_classes = (match Config.models_mode, Sys.file_exists Config.models_jar = `Yes with @@ -153,8 +152,15 @@ let main load_sources_and_classes = JClasspath.add_models Config.models_jar ); JBasics.set_permissive true; - let classpath, sources, classes = Lazy.force load_sources_and_classes in + let classpath, sources, classes = match load_sources_and_classes with + | `FromVerboseOut verbose_out_file -> + JClasspath.load_from_verbose_output verbose_out_file + | `FromArguments path -> + JClasspath.load_from_arguments path in if String.Map.is_empty sources then failwith "Failed to load any Java source code" else do_all_files classpath sources classes + +let from_arguments path = main (`FromArguments path) +let from_verbose_out verbose_out_file = main (`FromVerboseOut verbose_out_file) diff --git a/infer/src/java/jMain.mli b/infer/src/java/jMain.mli index 0cf1e7881..bd747c24e 100644 --- a/infer/src/java/jMain.mli +++ b/infer/src/java/jMain.mli @@ -10,4 +10,8 @@ open! IStd -val main: JClasspath.t Lazy.t -> unit +(** loads the source files from command line arguments and translates them *) +val from_arguments : string -> unit + +(** loads the source files from javac's verbose output translates them *) +val from_verbose_out : string -> unit diff --git a/infer/src/java_stubs/jMain.ml b/infer/src/java_stubs/jMain.ml index d3c0ba80c..369e2c6e1 100644 --- a/infer/src/java_stubs/jMain.ml +++ b/infer/src/java_stubs/jMain.ml @@ -7,4 +7,5 @@ * of patent rights can be found in the PATENTS file in the same directory. *) -let main _ = () +let from_arguments _ = () +let from_verbose_out _ = () diff --git a/infer/src/java_stubs/jMain.mli b/infer/src/java_stubs/jMain.mli deleted file mode 100644 index 6b65cbad0..000000000 --- a/infer/src/java_stubs/jMain.mli +++ /dev/null @@ -1,13 +0,0 @@ -(* - * Copyright (c) 2009 - 2013 Monoidics ltd. - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - *) - -open! IStd - -val main: 'a -> unit diff --git a/infer/src/java_stubs/jMain.mli b/infer/src/java_stubs/jMain.mli new file mode 120000 index 000000000..a94f776cf --- /dev/null +++ b/infer/src/java_stubs/jMain.mli @@ -0,0 +1 @@ +../java/jMain.mli \ No newline at end of file diff --git a/opam b/opam index 1092f1011..5ea4e1cd3 100644 --- a/opam +++ b/opam @@ -31,6 +31,7 @@ depends: [ "conf-autoconf" "ctypes" {>="0.9.2"} "ctypes-foreign" {>="0.4.0"} + "extlib-compat" "javalib" {>="2.3.3"} "ocamlfind" {build} "ounit" {="2.0.0"}