-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_clang.sh
executable file
·91 lines (77 loc) · 2.33 KB
/
build_clang.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
#!/bin/bash
target_plat="$1"
llvm_path="$2"
llvm_version="$3"
extra_params=
archive_plat=
case ${target_plat} in
linux-x86_64)
archive_plat="x86_64-linux"
;;
mac-x86_64)
archive_plat="x86_64-darwin"
;;
mac-arm64)
archive_plat="amd64-darwin"
;;
win32-x86_64)
archive_plat="x86_64-win32"
extra_params="-DCMAKE_C_COMPILER=${TOOLCHAIN_PATH}/x86_64-w64-mingw32-clang -DCMAKE_CXX_COMPILER=${TOOLCHAIN_PATH}/x86_64-w64-mingw32-clang++ -DCMAKE_RC_COMPILER=${TOOLCHAIN_PATH}/x86_64-w64-mingw32-windres -DCMAKE_SYSTEM_NAME=Windows -DCROSS_TOOLCHAIN_FLAGS_NATIVE=-DCMAKE_TOOLCHAIN_FILE=$(pwd)/Toolchain-NATIVE.cmake"
;;
*)
echo "Unknown platform: ${target_plat}" >&2
exit 1
;;
esac
if [ ! -d "${llvm_path}" ] ; then
echo "LLVM folder doesn't exist: ${llvm_path}"
exit 2
fi
if [ "${llvm_version}" == "" ] ; then
echo "LLVM version is not set"
exit 3
fi
flavor="${target_plat}"
pushd "${llvm_path}" > /dev/null
cmake -S llvm -B build-$flavor \
-G Ninja \
$EXTRA_PARAMS \
-DLLVM_ENABLE_THREADS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_TARGETS_TO_BUILD="" \
-DLLVM_STATIC_LINK_CXX_STDLIB=ON \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_ENABLE_PROJECTS="clang" \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DCMAKE_INSTALL_PREFIX=$(pwd)/usr-$flavor \
-DLLVM_STATIC_LINK_CXX_STDLIB=ON \
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON
if [ $? != 0 ] ; then
echo "Failed to generate build scripts for Clang" >&2
exit 4
fi
pushd build-$flavor > /dev/null
ninja
if [ $? != 0 ] ; then
echo "Failed to build Clang" >&2
exit 5
fi
ninja install
if [ $? != 0 ] ; then
echo "Failed to install Clang" >&2
exit 6
fi
popd > /dev/null
full_path=
pushd usr-$flavor > /dev/null
full_path="$(pwd)/llvm+clang-${llvm_version}-${archive_plat}.tar.xz"
tar cJvf ${full_path} *
popd > /dev/null
popd > /dev/null
echo "Get the archive at: ${full_path}"