Bug 861425 - Build the clang plugin on Mac; r=jcranmer

This commit is contained in:
Ehsan Akhgari 2014-05-31 09:13:32 -04:00
parent 38866397b0
commit b2db2316b2
3 changed files with 26 additions and 3 deletions

View File

@ -6,6 +6,8 @@ CXX := @CXX@
CXXFLAGS := @CXXFLAGS@
LDFLAGS := @LDFLAGS@
VPATH := @srcdir@
DSO_LDOPTS := @DSO_LDOPTS@
DLL_SUFFIX := @DLL_SUFFIX@
# Helper for end
NULL :=
@ -24,7 +26,7 @@ TESTSRCS := \
OBJS := $(patsubst %.cpp,%.o,$(CPPSRCS))
TESTS := $(patsubst %.cpp,test-%,$(TESTSRCS))
PLUGIN := libclang-plugin.so
PLUGIN := libclang-plugin.$(DLL_SUFFIX)
all: $(PLUGIN) $(TESTS)
@ -33,7 +35,7 @@ $(OBJS): %.o: %.cpp Makefile
$(PLUGIN): $(OBJS)
rm -f $@
$(CXX) -shared -o $@ $(CXXFLAGS) $(LDFLAGS) $(OBJS) -lclangASTMatchers
$(CXX) $(DSO_LDOPTS) -o $@ $(CXXFLAGS) $(OBJS) $(LDFLAGS)
TESTFLAGS := -fsyntax-only -Xclang -verify \
-Xclang -load -Xclang $(CURDIR)/$(PLUGIN) \

View File

@ -1,5 +1,7 @@
#!/bin/sh
PLATFORM=`uname`
# Default srcdir to this directory
srcdir=
@ -35,14 +37,31 @@ fi
echo "$LLVMCONFIG"
LLVMLIBS="core mc analysis asmparser mcparser bitreader"
LLVMCXXFLAGS=`$LLVMCONFIG --cxxflags`
LLVMLDFLAGS=`$LLVMCONFIG --ldflags`
LLVMLDFLAGS="$LLVMLDFLAGS `$LLVMCONFIG --libs $LLVMLIBS`"
if [ $PLATFORM == Darwin ]; then
DSO_LDOPTS="-dynamiclib -shared"
CLANGLDFLAGS="-lclangFrontend -lclangDriver -lclangSerialization \
-lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST \
-lclangLex -lclangBasic -lclangASTMatchers"
DLL_SUFFIX="dylib"
else
DSO_LDOPTS="-shared"
CLANGLDFLAGS=-lclangASTMatchers
DLL_SUFFIX="so"
fi
CXXFLAGS="$CXXFLAGS $LLVMCXXFLAGS -fno-rtti -fno-exceptions"
LDFLAGS="$LDFLAGS $LLVMLDFLAGS"
LDFLAGS="$LDFLAGS $LLVMLDFLAGS $CLANGLDFLAGS"
cat $srcdir/Makefile.in | sed \
-e "s%@CXX@%$CXX%" \
-e "s%@CXXFLAGS@%$CXXFLAGS%" \
-e "s%@LDFLAGS@%$LDFLAGS%" \
-e "s%@srcdir@%$srcdir%" \
-e "s%@DSO_LDOPTS@%$DSO_LDOPTS%" \
-e "s%@DLL_SUFFIX@%$DLL_SUFFIX%" \
> Makefile

View File

@ -8,10 +8,12 @@ if [ -d "$topsrcdir/clang" ]; then
# mozilla-central based build
export CC=$topsrcdir/clang/bin/clang
export CXX=$topsrcdir/clang/bin/clang++
export LLVMCONFIG=$topsrcdir/clang/bin/llvm-config
elif [ -d "$topsrcdir/../clang" ]; then
# comm-central based build
export CC=$topsrcdir/../clang/bin/clang
export CXX=$topsrcdir/../clang/bin/clang++
export LLVMCONFIG=$topsrcdir/../clang/bin/llvm-config
fi
# If not set use the system default clang