forked from tpoechtrager/apple-libtapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·106 lines (86 loc) · 2.76 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
set -e
TAPI_VERSION=1300.6.5
pushd "${0%/*}" &>/dev/null
source tools/tools.sh
if [[ $(basename $0) == *tapi_tools* ]]; then
BUILD_TAPI_TOOLS=1
[[ "$CC" != *clang* ]] && export CC="clang"
[[ "$CXX" != *clang++* ]] && export CXX="clang++"
which lld &>/dev/null || {
echo "Missing lld" 1>&2
exit 1
}
CMAKE_EXE_LINKER_FLAGS+=" -fuse-ld=lld"
CMAKE_SHARED_LINKER_FLAGS+=" -fuse-ld=lld"
fi
rm -rf build
mkdir build
pushd build &>/dev/null
CMAKE_EXTRA_ARGS=""
if [ $OPERATING_SYSTEM == "Android" ]; then
export CC="$CC -D__ANDROID_API__=26"
export CXX="$CXX -D__ANDROID_API__=26"
fi
if [ "$TARGET" == "Darwin" ]; then
#export MACOSX_DEPLOYMENT_TARGET=10.9
CMAKE_EXTRA_ARGS+="-DCMAKE_SYSTEM_NAME=Darwin "
export CC="$(xcrun -f clang) -stdlib=libc++"
export CXX="$(xcrun -f clang++) -stdlib=libc++"
elif [ "$TARGET" == "iOS" ]; then
unset MACOSX_DEPLOYMENT_TARGET
CMAKE_EXTRA_ARGS+="-DCMAKE_SYSTEM_NAME=Darwin "
export CC="arm-apple-darwin11-clang -stdlib=libc++"
export CXX="arm-apple-darwin11-clang++ -stdlib=libc++"
elif [ "$TARGET" == "iOS-ARMV7" ]; then
unset MACOSX_DEPLOYMENT_TARGET
CMAKE_EXTRA_ARGS+="-DCMAKE_SYSTEM_NAME=Darwin "
export CC="arm-apple-darwin11-clang -arch armv7 -stdlib=libc++"
export CXX="arm-apple-darwin11-clang++ -arch armv7 -stdlib=libc++"
elif [ "$TARGET" == "FreeBSD" ]; then
CMAKE_EXTRA_ARGS+="-DCMAKE_SYSTEM_NAME=FreeBSD "
export CC=amd64-pc-freebsd13.0-clang
export CXX=amd64-pc-freebsd13.0-clang++
elif [ "$TARGET" == "MINGW64" ]; then
CMAKE_EXTRA_ARGS+="-DCMAKE_SYSTEM_NAME=Windows "
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
elif [ "$TARGET" == "MINGW32" ]; then
CMAKE_EXTRA_ARGS+="-DCMAKE_SYSTEM_NAME=Windows "
export CC=i686-w64-mingw32-gcc
export CXX=i686-w64-mingw32-g++
fi
if [ -z "$INSTALLPREFIX" ]; then
INSTALLPREFIX="/usr/local"
fi
# TODO: Fix this in a better way.
INCLUDE_FIX="-I $PWD/../src/llvm/projects/clang/include "
INCLUDE_FIX+="-I $PWD/projects/clang/include "
echo -n $INSTALLPREFIX > INSTALLPREFIX
cmake ../src/llvm \
-DCMAKE_CXX_FLAGS="$INCLUDE_FIX" \
-DCMAKE_SHARED_LINKER_FLAGS="$CMAKE_SHARED_LINKER_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" \
-DLLVM_INCLUDE_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DLLVM_ENABLE_PROJECTS="tapi;clang" \
-DCMAKE_INSTALL_PREFIX=$INSTALLPREFIX \
-DTAPI_REPOSITORY_STRING=$TAPI_VERSION \
-DTAPI_FULL_VERSION=$TAPI_VERSION \
$CMAKE_EXTRA_ARGS
echo ""
echo "## Building clangBasic ##"
echo ""
$MAKE clangBasic -j $JOBS
echo ""
echo "## Building libtapi ##"
echo ""
$MAKE libtapi -j $JOBS
if [ -n "$BUILD_TAPI_TOOLS" ]; then
echo ""
echo "## Building tapi tools ##"
echo ""
$MAKE tapi tapi-binary-reader tapi-run tapi-sdkdb -j $JOBS
fi
popd &>/dev/null
popd &>/dev/null