-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathbuild.sh
executable file
·88 lines (68 loc) · 1.86 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
#!/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++"
command -v lld &>/dev/null || command -v ld.lld &>/dev/null || command -v ld64.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
if [ "$NINJA" = 1 ]; then
command -v ninja &>/dev/null || {
echo "Missing ninja" 1>&2
exit 1
}
cmakegen="Ninja"
MAKE="ninja"
else
cmakegen="Unix Makefiles"
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 [ -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 "
printf '%s' "$INSTALLPREFIX" > INSTALLPREFIX
cmake -G "$cmakegen" ../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