diff --git a/Makefile.autoconf.in b/Makefile.autoconf.in index 547ed66c0..5ce651cc5 100644 --- a/Makefile.autoconf.in +++ b/Makefile.autoconf.in @@ -10,6 +10,7 @@ ATDGEN = @ATDGEN@ bindir = @bindir@ BUCK = @BUCK@ BUILD_C_ANALYZERS = @BUILD_C_ANALYZERS@ +BUILD_ERLANG_ANALYZERS = @BUILD_ERLANG_ANALYZERS@ BUILD_JAVA_ANALYZERS = @BUILD_JAVA_ANALYZERS@ BUILD_PLATFORM = @BUILD_PLATFORM@ CAML_LD_LIBRARY_PATH = @CAML_LD_LIBRARY_PATH@ diff --git a/build-infer.sh b/build-infer.sh index 69d4050d8..9be608fab 100755 --- a/build-infer.sh +++ b/build-infer.sh @@ -31,6 +31,7 @@ function usage() { echo " targets:" echo " all build everything (default)" echo " clang build C and Objective-C analyzer" + echo " erlang build Erlang analyzer" echo " java build Java analyzer" echo echo " options:" @@ -41,13 +42,14 @@ function usage() { echo " -y,--yes automatically agree to everything" echo echo " examples:" - echo " $0 # build Java and C/Objective-C analyzers" - echo " $0 java clang # equivalent way of doing the above" - echo " $0 java # build only the Java analyzer" + echo " $0 # build Java, Erlang and C/Objective-C analyzers" + echo " $0 java erlang clang # equivalent way of doing the above" + echo " $0 java # build only the Java analyzer" } # arguments BUILD_CLANG=${BUILD_CLANG:-no} +BUILD_ERLANG=${BUILD_ERLANG:-no} BUILD_JAVA=${BUILD_JAVA:-no} INFER_CONFIGURE_OPTS=${INFER_CONFIGURE_OPTS:-""} INTERACTIVE=${INTERACTIVE:-yes} @@ -58,12 +60,17 @@ USER_OPAM_SWITCH=no ORIG_ARGS="$*" +function build_all() { + BUILD_CLANG=yes + BUILD_ERLANG=yes + BUILD_JAVA=yes +} + while [[ $# -gt 0 ]]; do opt_key="$1" case $opt_key in all) - BUILD_CLANG=yes - BUILD_JAVA=yes + build_all shift continue ;; @@ -72,6 +79,11 @@ while [[ $# -gt 0 ]]; do shift continue ;; + erlang) + BUILD_ERLANG=yes + shift + continue + ;; java) BUILD_JAVA=yes shift @@ -108,10 +120,8 @@ while [[ $# -gt 0 ]]; do shift done -# if no arguments then build both clang and Java -if [ "$BUILD_CLANG" == "no" ] && [ "$BUILD_JAVA" == "no" ]; then - BUILD_CLANG=yes - BUILD_JAVA=yes +if [ "$BUILD_CLANG" == "no" ] && [ "$BUILD_ERLANG" == "no" ] && [ "$BUILD_JAVA" == "no" ]; then + build_all fi # enable --yes option for some commands in non-interactive mode @@ -161,6 +171,9 @@ echo "preparing build... " >&2 if [ "$BUILD_CLANG" == "no" ]; then INFER_CONFIGURE_OPTS+=" --disable-c-analyzers" fi +if [ "$BUILD_ERLANG" == "no" ]; then + INFER_CONFIGURE_OPTS+=" --disable-erlang-analyzers" +fi if [ "$BUILD_JAVA" == "no" ]; then INFER_CONFIGURE_OPTS+=" --disable-java-analyzers" fi diff --git a/configure.ac b/configure.ac index 62bf8d019..a5c35441d 100644 --- a/configure.ac +++ b/configure.ac @@ -91,12 +91,19 @@ AC_ARG_ENABLE(c-analyzers, BUILD_C_ANALYZERS=$enable_c_analyzers AC_SUBST([BUILD_C_ANALYZERS]) +AC_ARG_ENABLE(erlang-analyzers, + AS_HELP_STRING([--disable-erlang-analyzers], + [do not build the Erlang analyzers (default is to build them)]), + , + enable_erlang_analyzers=yes) +BUILD_ERLANG_ANALYZERS=$enable_erlang_analyzers +AC_SUBST([BUILD_ERLANG_ANALYZERS]) + AC_ARG_ENABLE(java-analyzers, AS_HELP_STRING([--disable-java-analyzers], [do not build the Java analyzers (default is to build them)]), , enable_java_analyzers=yes) - BUILD_JAVA_ANALYZERS=$enable_java_analyzers AC_SUBST([BUILD_JAVA_ANALYZERS]) diff --git a/infer/man/man1/infer-capture.txt b/infer/man/man1/infer-capture.txt index f6264d9da..05a66117f 100644 --- a/infer/man/man1/infer-capture.txt +++ b/infer/man/man1/infer-capture.txt @@ -64,7 +64,7 @@ OPTIONS Proceed as if the first argument after -- was command. Possible values: ant, buck, gradle, gradlew, java, javac, cc, clang, gcc, clang++, c++, g++, make, configure, cmake, waf, mvn, mvnw, - ndk-build, xcodebuild. + ndk-build, rebar3, xcodebuild. --help Show this manual diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 521109e23..49bd65d7d 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -638,7 +638,7 @@ OPTIONS Proceed as if the first argument after -- was command. Possible values: ant, buck, gradle, gradlew, java, javac, cc, clang, gcc, clang++, c++, g++, make, configure, cmake, waf, mvn, mvnw, - ndk-build, xcodebuild. See also infer-capture(1) and infer-run(1). + ndk-build, rebar3, xcodebuild. See also infer-capture(1) and infer-run(1). --no-fragment-retains-view Deactivates: checker fragment-retains-view: Detects when Android diff --git a/infer/man/man1/infer-run.txt b/infer/man/man1/infer-run.txt index 6a68e9e45..bebe47f41 100644 --- a/infer/man/man1/infer-run.txt +++ b/infer/man/man1/infer-run.txt @@ -74,7 +74,7 @@ OPTIONS Proceed as if the first argument after -- was command. Possible values: ant, buck, gradle, gradlew, java, javac, cc, clang, gcc, clang++, c++, g++, make, configure, cmake, waf, mvn, mvnw, - ndk-build, xcodebuild. + ndk-build, rebar3, xcodebuild. --help Show this manual diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 3d7a1ae49..e798ae109 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -638,7 +638,7 @@ OPTIONS Proceed as if the first argument after -- was command. Possible values: ant, buck, gradle, gradlew, java, javac, cc, clang, gcc, clang++, c++, g++, make, configure, cmake, waf, mvn, mvnw, - ndk-build, xcodebuild. See also infer-capture(1) and infer-run(1). + ndk-build, rebar3, xcodebuild. See also infer-capture(1) and infer-run(1). --no-fragment-retains-view Deactivates: checker fragment-retains-view: Detects when Android diff --git a/infer/src/Makefile b/infer/src/Makefile index dcd8761f5..dfcf602cc 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -234,6 +234,7 @@ $(GENERATED_FROM_AUTOCONF): $(MAKEFILE_LIST) -e "s|@INFER_GIT_BRANCH[@]|$$INFER_GIT_BRANCH|g" \ -e "s|@JAVA_MAJOR_VERSION[@]|$(JAVA_MAJOR_VERSION)|g" \ -e "s|@BUILD_C_ANALYZERS[@]|$(BUILD_C_ANALYZERS)|g" \ + -e "s|@BUILD_ERLANG_ANALYZERS[@]|$(BUILD_ERLANG_ANALYZERS)|g" \ -e "s|@BUILD_JAVA_ANALYZERS[@]|$(BUILD_JAVA_ANALYZERS)|g" \ -e "s|@BUILD_PLATFORM[@]|$(BUILD_PLATFORM)|g" \ -e "s|@OPAMSWITCH[@]|$(OPAMSWITCH)|g" \ diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index fcdd1df5a..262167f95 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -42,6 +42,7 @@ type build_system = | BMake | BMvn | BNdk + | BRebar3 | BXcode [@@deriving compare] @@ -72,6 +73,7 @@ let build_system_exe_assoc = ; (BMvn, "mvn") ; (BMvn, "mvnw") ; (BNdk, "ndk-build") + ; (BRebar3, "rebar3") ; (BXcode, "xcodebuild") ] diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 55070b320..4e91df80a 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -23,6 +23,7 @@ type build_system = | BMake | BMvn | BNdk + | BRebar3 | BXcode type scheduler = File | Restart | SyntacticCallGraph [@@deriving equal] diff --git a/infer/src/base/Version.ml.in b/infer/src/base/Version.ml.in index 968e5d625..7d6ddc148 100644 --- a/infer/src/base/Version.ml.in +++ b/infer/src/base/Version.ml.in @@ -49,6 +49,8 @@ let java_enabled = is_yes "@BUILD_JAVA_ANALYZERS@" let java_version = int_of_string_opt "@JAVA_MAJOR_VERSION@" +let erlang_enabled = is_yes "@BUILD_ERLANG_ANALYZERS@" + let xcode_enabled = is_not_no "@XCODE_SELECT@" let man_pages_last_modify_date = "@INFER_MAN_LAST_MODIFIED@" diff --git a/infer/src/base/Version.mli b/infer/src/base/Version.mli index bfb5f462b..24efaf580 100644 --- a/infer/src/base/Version.mli +++ b/infer/src/base/Version.mli @@ -29,6 +29,8 @@ val java_enabled : bool val java_version : int option +val erlang_enabled : bool + val xcode_enabled : bool val man_pages_last_modify_date : string diff --git a/infer/src/dune.common.in b/infer/src/dune.common.in index a37fa6870..bf5a3467e 100644 --- a/infer/src/dune.common.in +++ b/infer/src/dune.common.in @@ -15,6 +15,8 @@ let clang = is_yes "@BUILD_C_ANALYZERS@" let java = is_yes "@BUILD_JAVA_ANALYZERS@" +let erlang = is_yes "@BUILD_ERLANG_ANALYZERS@" + let facebook = is_yes "@IS_FACEBOOK_TREE@" let extra_cflags = if is_empty "@EXTRA_CFLAGS@" then [] else ["@EXTRA_CFLAGS@"] diff --git a/infer/src/integration/Driver.ml b/infer/src/integration/Driver.ml index 24bc755d0..3fb0b227c 100644 --- a/infer/src/integration/Driver.ml +++ b/infer/src/integration/Driver.ml @@ -27,6 +27,7 @@ type mode = | Javac of {compiler: Javac.compiler; prog: string; args: string list} | Maven of {prog: string; args: string list} | NdkBuild of {build_cmd: string list} + | Rebar3 of {args: string list} | XcodeBuild of {prog: string; args: string list} | XcodeXcpretty of {prog: string; args: string list} @@ -60,6 +61,8 @@ let pp_mode fmt = function F.fprintf fmt "Maven driver mode:@\nprog = '%s'@\nargs = %a" prog Pp.cli_args args | NdkBuild {build_cmd} -> F.fprintf fmt "NdkBuild driver mode: build_cmd = %a" Pp.cli_args build_cmd + | Rebar3 {args} -> + F.fprintf fmt "Rebar3 driver mode:@\nargs = %a" Pp.cli_args args | XcodeBuild {prog; args} -> F.fprintf fmt "XcodeBuild driver mode:@\nprog = '%s'@\nargs = %a" prog Pp.cli_args args | XcodeXcpretty {prog; args} -> @@ -139,6 +142,9 @@ let capture ~changed_files = function | NdkBuild {build_cmd} -> L.progress "Capturing in ndk-build mode...@." ; NdkBuild.capture ~build_cmd + | Rebar3 {args} -> + L.progress "Capturing in rebar3 mode...@." ; + Rebar3.capture ~args | XcodeBuild {prog; args} -> L.progress "Capturing in xcodebuild mode...@." ; XcodeBuild.capture ~prog ~args @@ -302,6 +308,8 @@ let assert_supported_mode required_analyzer requested_mode_string = Version.clang_enabled && Version.java_enabled | `Java -> Version.java_enabled + | `Erlang -> + Version.erlang_enabled | `Xcode -> Version.clang_enabled && Version.xcode_enabled in @@ -314,6 +322,8 @@ let assert_supported_mode required_analyzer requested_mode_string = "clang & java" | `Java -> "java" + | `Erlang -> + "erlang" | `Xcode -> "clang and xcode" in @@ -336,6 +346,8 @@ let assert_supported_build_system build_system = Config.string_of_build_system build_system |> assert_supported_mode `Java | BClang | BMake | BNdk -> Config.string_of_build_system build_system |> assert_supported_mode `Clang + | BRebar3 -> + Config.string_of_build_system build_system |> assert_supported_mode `Erlang | BXcode -> Config.string_of_build_system build_system |> assert_supported_mode `Xcode | BBuck -> @@ -399,6 +411,8 @@ let mode_of_build_command build_cmd (buck_mode : BuckMode.t option) = Maven {prog; args} | BNdk, _ -> NdkBuild {build_cmd} + | BRebar3, _ -> + Rebar3 {args} | BXcode, _ when Config.xcpretty -> XcodeXcpretty {prog; args} | BXcode, _ -> diff --git a/infer/src/integration/Driver.mli b/infer/src/integration/Driver.mli index 81ea0cc71..12c05f202 100644 --- a/infer/src/integration/Driver.mli +++ b/infer/src/integration/Driver.mli @@ -25,6 +25,7 @@ type mode = | Javac of {compiler: Javac.compiler; prog: string; args: string list} | Maven of {prog: string; args: string list} | NdkBuild of {build_cmd: string list} + | Rebar3 of {args: string list} | XcodeBuild of {prog: string; args: string list} | XcodeXcpretty of {prog: string; args: string list} diff --git a/infer/src/integration/Rebar3.ml b/infer/src/integration/Rebar3.ml new file mode 100644 index 000000000..e5ab5b092 --- /dev/null +++ b/infer/src/integration/Rebar3.ml @@ -0,0 +1,11 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd + +(* TODO *) +let capture ~args:_ = () diff --git a/infer/src/integration/Rebar3.mli b/infer/src/integration/Rebar3.mli new file mode 100644 index 000000000..355f7cb8f --- /dev/null +++ b/infer/src/integration/Rebar3.mli @@ -0,0 +1,10 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd + +val capture : args:string list -> unit