compile plugin from toplevel Makefile

Summary:
public
Remove ./compile-fcp.sh script and put these functionalities inside the
toplevel Makefile.

NOTE: this will cause a recompilation of clang. To avoid this, run:

- on macos:

  ./autogen.sh
  cd facebook-clang-plugins/clang/
  shasum -a 256 -p ./setup.sh src/clang-snapshot-20-11-15.tar.xz > installed.version

- on linux:

  ./autogen.sh
  cd facebook-clang-plugins/clang/
  sha256sum ./setup.sh src/clang-snapshot-20-11-15.tar.xz > installed.version

Reviewed By: jeremydubreil

Differential Revision: D2703948

fb-gh-sync-id: 721bb03
master
Jules Villard 9 years ago committed by facebook-github-bot-1
parent d99b6ca492
commit ecc6e763d4

@ -9,6 +9,7 @@ PLATFORM = $(shell uname)
ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd) ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd)
FCP_DIR = $(ABSOLUTE_ROOT_DIR)/facebook-clang-plugins
INFER_DIR = $(ABSOLUTE_ROOT_DIR)/infer INFER_DIR = $(ABSOLUTE_ROOT_DIR)/infer
DEPENDENCIES_DIR = $(ABSOLUTE_ROOT_DIR)/dependencies DEPENDENCIES_DIR = $(ABSOLUTE_ROOT_DIR)/dependencies
FCP_DIR = $(ABSOLUTE_ROOT_DIR)/facebook-clang-plugins FCP_DIR = $(ABSOLUTE_ROOT_DIR)/facebook-clang-plugins

@ -14,10 +14,35 @@ all: clang java
java: java:
$(MAKE) -C $(INFER_DIR) java $(MAKE) -C $(INFER_DIR) java
clang: clang_setup:
export CC="@CC@" CFLAGS="@CFLAGS@"; \
export CXX="@CXX@" CXXFLAGS="@CXXFLAGS@"; \
export CPP="@CPP@" LDFLAGS="@LDFLAGS@" LIBS="@LIBS@"; \
$(FCP_DIR)/clang/setup.sh
clang_plugin: clang_setup
$(MAKE) -C $(FCP_DIR)/libtooling all \
CC=@CC@ CXX=@CXX@ \
CXX="@CXX@" CXXFLAGS="@CXXFLAGS@" \
CPP="@CPP@" LDFLAGS="@LDFLAGS@" LIBS="@LIBS@" \
LOCAL_CLANG=@CLANG_PREFIX@/bin/clang \
CLANG_PREFIX=@CLANG_PREFIX@ \
CLANG_INCLUDES=@CLANG_INCLUDES@
$(MAKE) -C $(FCP_DIR)/clang-ocaml all \
build/clang_ast_proj.ml build/clang_ast_proj.mli \
CC=@CC@ CXX=@CXX@ \
CXX="@CXX@" CXXFLAGS="@CXXFLAGS@" \
CPP="@CPP@" LDFLAGS="@LDFLAGS@" LIBS="@LIBS@" \
LOCAL_CLANG=@CLANG_PREFIX@/bin/clang \
CLANG_PREFIX=@CLANG_PREFIX@ \
CLANG_INCLUDES=@CLANG_INCLUDES@
clang: clang_plugin
$(MAKE) -C $(INFER_DIR) clang $(MAKE) -C $(INFER_DIR) clang
clean: clean:
$(MAKE) -C $(FCP_DIR) clean
$(MAKE) -C $(FCP_DIR)/clang-ocaml clean
$(MAKE) -C $(INFER_DIR) clean $(MAKE) -C $(INFER_DIR) clean
.PHONY: all clean clang java .PHONY: all clean clang clang_plugin clang_setup java

@ -113,40 +113,35 @@ if [ "$BUILD_JAVA" = "1" ]; then
fi fi
if [ "$BUILD_CLANG" = "1" ]; then if [ "$BUILD_CLANG" = "1" ]; then
TARGETS+=" clang" TARGETS+=" clang"
if [ ! -f .release ]; then if ! facebook-clang-plugins/clang/setup.sh --only-check-install; then
if ! facebook-clang-plugins/clang/setup.sh --only-check-install; then echo ""
echo "" echo " Warning: you are not using a release of Infer. The C and"
echo " Warning: you are not using a release of Infer. The C and" echo " Objective-C analyses require a custom clang to be compiled"
echo " Objective-C analyses require a custom clang to be compiled" echo " now. This step takes ~30-60 minutes, possibly more."
echo " now. This step takes ~30-60 minutes, possibly more." echo ""
echo "" echo " To speed this along, you are encouraged to use a release of"
echo " To speed this along, you are encouraged to use a release of" echo " Infer instead:"
echo " Infer instead:" echo ""
echo "" echo " http://fbinfer.com/docs/getting-started.html"
echo " http://fbinfer.com/docs/getting-started.html" echo ""
echo "" echo " If you are only interested in analyzing Java programs, simply"
echo " If you are only interested in analyzing Java programs, simply" echo " run this script with only the \"java\" argument:"
echo " run this script with only the \"java\" argument:" echo ""
echo "" echo " $0 java"
echo " $0 java" echo ""
echo ""
confirm="n"
confirm="n" printf "Are you sure you want to compile clang? (y/N) "
printf "Are you sure you want to compile clang? (y/N) " if [ "$INTERACTIVE" = "no" ]; then
if [ "$INTERACTIVE" = "no" ]; then confirm="y"
confirm="y" echo "$confirm"
echo "$confirm" else
else read confirm
read confirm fi
fi
if [ "x$confirm" != "xy" ]; then
if [ "x$confirm" != "xy" ]; then exit 0
exit 0
fi
./facebook-clang-plugins/clang/setup.sh
fi fi
./compile-fcp.sh
fi fi
fi fi

@ -1,53 +0,0 @@
#!/bin/bash
# Copyright (c) 2015 - 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.
set -e
set -x
# This script installs the facebook-clang-plugins
INFER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PLUGIN_DIR="$INFER_ROOT/facebook-clang-plugins"
CLANG_EXEC="$PLUGIN_DIR/clang/bin/clang"
# check if clang is available
if [ ! -f $CLANG_EXEC ]; then
echo "Clang has not been found in $CLANG_EXEC" && exit 1
fi
# install facebook-clang-plugins
pushd "$PLUGIN_DIR"
# prepare flags for the compilation on the Linux platform
platform="$(uname)"
if [ "$platform" == 'Linux' ]; then
export SDKPATH=""
export PATH="$PLUGIN_DIR/clang/bin:$PATH"
[ -z "$CC" ] && export CC="$PLUGIN_DIR/clang/bin/clang"
make_vars+=" CC=$CC"
[ -z "$CXX" ] && export CXX="$PLUGIN_DIR/clang/bin/clang++"
make_vars+=" CXX=$CXX"
[ -z "$CLANG_PREFIX" ] && export CLANG_PREFIX="$PLUGIN_DIR/clang"
[ -z "$LLVM_INCLUDES" ] && export LLVM_INCLUDES="$PLUGIN_DIR/clang/include"
[ -z "$CLANG_INCLUDES" ] && export CLANG_INCLUDES="$LLVM_INCLUDES $CLANG_PREFIX/include"
fi
# compile
make clean
make -C clang-ocaml clean
make $make_vars
make -C clang-ocaml all build/clang_ast_proj.ml build/clang_ast_proj.mli
popd
# check YojsonASTExporter works with clang
echo "int main() { return 0; }" | \
$CLANG_EXEC -o /dev/null -x c \
-Xclang -load -Xclang $PLUGIN_DIR/libtooling/build/FacebookClangPlugin.dylib \
-Xclang -plugin -Xclang BiniouASTExporter -c - > /dev/null \
|| { echo "$CLANG_EXEC and the facebook-clang-plugins are not working.";
echo "Check you're using the right revision of clang, then retry"; exit 1; }

@ -15,12 +15,12 @@ AC_PREREQ([2.63])
AC_INIT([Infer],[0.4.0],[https://github.com/facebook/infer/issues/]) AC_INIT([Infer],[0.4.0],[https://github.com/facebook/infer/issues/])
AC_CONFIG_SRCDIR([infer/src/backend/sil.ml]) AC_CONFIG_SRCDIR([infer/src/backend/sil.ml])
#AC_CONFIG_HEADERS([config.h])
# Checks for programs. # prefer clang over gcc because the plugins makes use of
AC_PROG_CXX # clang-specific #pragma's
AC_PROG_CC(clang gcc)
AC_PROG_CXX(clang++ g++)
AC_PROG_AWK AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP AC_PROG_CPP
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_LN_S AC_PROG_LN_S
@ -68,6 +68,17 @@ AC_SUBST([ATDGEN])
AC_CHECK_TOOL([XCODE_SELECT], [xcode-select], [no]) AC_CHECK_TOOL([XCODE_SELECT], [xcode-select], [no])
AC_SUBST([XCODE_SELECT]) AC_SUBST([XCODE_SELECT])
# to compile the facebook-clang-plugins
AC_ARG_VAR([CLANG_PREFIX], [directory where clang is installed (defaults=$PWD/facebook-clang-plugins/clang)])
AS_IF([test "x$CLANG_PREFIX" = "x"], [
CLANG_PREFIX="$(pwd)/facebook-clang-plugins/clang"
])
AC_ARG_VAR([CLANG_INCLUDES], [clang headers directories (defaults=$CLANG_PREFIX/include)])
AS_IF([test "x$CLANG_INCLUDES" = "x"], [
CLANG_INCLUDES="$CLANG_PREFIX/include"
])
# Checks for header files. # Checks for header files.
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h locale.h malloc.h stddef.h stdint.h stdlib.h string.h sys/mount.h sys/param.h sys/socket.h sys/statfs.h sys/time.h unistd.h wchar.h wctype.h]) AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h locale.h malloc.h stddef.h stdint.h stdlib.h string.h sys/mount.h sys/param.h sys/socket.h sys/statfs.h sys/time.h unistd.h wchar.h wctype.h])

Loading…
Cancel
Save