From 4792e37a734b617e235f5a2c86974a572d83c98c Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Fri, 28 Jul 2017 05:58:33 -0700 Subject: [PATCH] [make] kill PATH hack Reviewed By: mbouaziz Differential Revision: D5470571 fbshipit-source-id: bde1ada --- Makefile.autoconf.in | 5 +---- configure.ac | 31 +++++++++++++------------------ infer/models/models-config.make | 21 +++++++++++++++++++++ infer/models/objc/src/Makefile | 7 ++++--- 4 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 infer/models/models-config.make diff --git a/Makefile.autoconf.in b/Makefile.autoconf.in index 33b474566..c733943cf 100644 --- a/Makefile.autoconf.in +++ b/Makefile.autoconf.in @@ -75,8 +75,5 @@ LN_S = @LN_S@ -v endif # Export parts of the config relevant to running other programs -# be merciful and allow PATH to be updated between ./configure and make -# except for OCaml-related executables -# TODO(17630614) get rid of this hack -export PATH := $(dir $(OCAMLC)):$(shell printf "%s" "$$PATH"):$(PATH) +export PATH := $(PATH) export CAML_LD_LIBRARY_PATH := $(CAML_LD_LIBRARY_PATH) diff --git a/configure.ac b/configure.ac index 68987ef36..3a226476a 100644 --- a/configure.ac +++ b/configure.ac @@ -96,7 +96,7 @@ AS_IF([test "x$enable_c_analyzers" = "xyes"], [ AC_CHECK_TOOL([SHASUM], [shasum], [no]) AC_ASSERT_PROG([shasum], [$SHASUM]) # cmake is required to build llvm+clang - AC_PATH_TOOL([CMAKE], [cmake], [no]) + AC_CHECK_TOOL([CMAKE], [cmake], [no]) AS_IF([test "x$is_release_tree" = "xno"], [ AC_ASSERT_PROG([cmake], [$CMAKE]) ]) @@ -113,7 +113,7 @@ AS_IF([test "x$enable_c_analyzers" = "xyes"], [ AC_CHECK_TOOL([PYTHON27], [python2.7], [no]) AC_ASSERT_PROG([python2.7], [$PYTHON27]) -AC_PATH_TOOL([XCODE_SELECT], [xcode-select], [no]) +AC_CHECK_TOOL([XCODE_SELECT], [xcode-select], [no]) # prefer clang over gcc because the plugins makes use of @@ -175,12 +175,12 @@ AC_ASSERT_PROG([ocamlc], [$OCAMLC]) # check the version of OCaml AC_ASSERT_OCAML_MIN_VERSION([4.04.2]) AC_ASSERT_PROG([ocamlopt], [$OCAMLOPT]) -AC_PATH_TOOL([OCAMLBUILD], [ocamlbuild], [no]) +AC_CHECK_TOOL([OCAMLBUILD], [ocamlbuild], [no]) AC_ASSERT_PROG([ocamlbuild], [$OCAMLBUILD]) AC_PROG_FINDLIB AC_PROG_OCAMLLEX AC_ASSERT_PROG([ocamllex], [$OCAMLLEX]) -AC_PATH_TOOL([MENHIR], [menhir], [no]) +AC_CHECK_TOOL([MENHIR], [menhir], [no]) AC_ASSERT_PROG([menhir], [$MENHIR]) AC_ASSERT_OCAML_PKG([atdgen], [], []) AC_ASSERT_OCAML_PKG([biniou]) @@ -203,7 +203,7 @@ AC_SUBST([OPAMSWITCH]) if test "x$enable_java_analyzers" = "xyes"; then AC_CHECK_TOOL([JAVA], [java], [no]) - AC_PATH_TOOL([JAVAC], [javac], [no]) + AC_CHECK_TOOL([JAVAC], [javac], [no]) AC_ASSERT_PROG([javac], [$JAVAC]) AC_ASSERT_PROG([java], [$JAVA]) AC_ASSERT_OCAML_PKG([javalib], [], [2.3.3]) @@ -240,7 +240,7 @@ _ACEOF fi # end if($enable_java_analyzers) -AC_PATH_TOOL([ATDGEN], [atdgen], [no]) +AC_CHECK_TOOL([ATDGEN], [atdgen], [no]) AC_ASSERT_PROG([atdgen], [$ATDGEN]) AC_ARG_ENABLE(ocaml-bin-annot, @@ -262,7 +262,7 @@ cat "$buckversion_file" > ".buckversion" AC_MSG_RESULT([$buckversion_file]) -AC_PATH_TOOL([GETCONF], [getconf], [no]) +AC_CHECK_TOOL([GETCONF], [getconf], [no]) AC_MSG_CHECKING([the number of cpus the build host has]) if test "$GETCONF" != "no"; then if test $("$GETCONF" _NPROCESSORS_ONLN); then @@ -277,20 +277,15 @@ AC_SUBST([NCPU]) # optional progs and libraries that, eg build systems to be run in integration tests -AC_PATH_TOOL([ANT], [ant], [no]) -if test ! -z "$SANDCASTLE"; then - BUCK=buck - AC_SUBST([BUCK]) -else - AC_PATH_TOOL([BUCK], [buck], [no]) -fi +AC_CHECK_TOOL([ANT], [ant], [no]) +AC_CHECK_TOOL([BUCK], [buck], [no]) AC_ARG_VAR([MVN], [command to execute Maven when running tests]) AS_IF([test "x$MVN" = "x"], [ - AC_PATH_TOOL([MVN], [mvn], [no]) + AC_CHECK_TOOL([MVN], [mvn], [no]) ], [ AC_MSG_RESULT([checking for mvn... $MVN]) ]) -AC_PATH_TOOL([NDKBUILD], [ndk-build], [no]) +AC_CHECK_TOOL([NDKBUILD], [ndk-build], [no]) if test x"$NDKBUILD" = x"no"; then # ndk-build not in $PATH, look into potential android NDK install paths and record the absolute path # to ndk-build @@ -300,9 +295,9 @@ fi AC_CHECK_PYTHON_MODULE([$PYTHON27], [lxml]) -AC_PATH_TOOL([XCPRETTY], [xcpretty], [no]) +AC_CHECK_TOOL([XCPRETTY], [xcpretty], [no]) -AC_PATH_TOOL([BREW], [brew], [no]) +AC_CHECK_TOOL([BREW], [brew], [no]) # warn about broken pkg-config version for brew users if test "$BREW" != "no"; then diff --git a/infer/models/models-config.make b/infer/models/models-config.make new file mode 100644 index 000000000..33e6ea0b3 --- /dev/null +++ b/infer/models/models-config.make @@ -0,0 +1,21 @@ +# Copyright (c) 2017 - 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. + +# you have to set MODELS_DIR to infer/models/ before including this file + +# We want infer to still be able to override PATH so that it can capture compilation +# commands. Makefile.config will override PATH to be the configure-time one, which defeats +# infer. +# +# When called from our models Makefile PATH will be set by Makefile.config already, then infer will +# add its wrappers, so we can trust the original PATH here. +# +# Save the original PATH, include Makefile.config, and use the original PATH. +ORIGPATH = $(shell printf "%s" "$$PATH") +ROOT_DIR = $(MODELS_DIR)/../.. +include $(ROOT_DIR)/Makefile.config +export PATH := $(ORIGPATH) diff --git a/infer/models/objc/src/Makefile b/infer/models/objc/src/Makefile index ffceba265..9a096e8fa 100644 --- a/infer/models/objc/src/Makefile +++ b/infer/models/objc/src/Makefile @@ -5,16 +5,17 @@ # 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. -ROOT_DIR = ../../../.. -include $(ROOT_DIR)/Makefile.config +MODELS_DIR = ../.. +include $(MODELS_DIR)/models-config.make M_SOURCES=$(shell find . -name "*.m") C_SOURCES=$(shell find . -name "*.c") OBJECTS=$(M_SOURCES:.m=.o) $(C_SOURCES:.c=.o) +# let infer override CC by letting the shell resolve its location according to PATH CC=clang XCODE_PATH=$(shell $(XCODE_SELECT) -p) IPHONE_SIMULATOR_PATH=$(XCODE_PATH)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -CFLAGS=--target=x86_64-apple-darwin14 -x objective-c -c -mios-simulator-version-min=8.2 -isysroot $(IPHONE_SIMULATOR_PATH) +CFLAGS += --target=x86_64-apple-darwin14 -x objective-c -c -mios-simulator-version-min=8.2 -isysroot $(IPHONE_SIMULATOR_PATH) all: $(OBJECTS)