This repository has been archived by the owner on Sep 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·99 lines (90 loc) · 2.12 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
#!/bin/bash
result_args=""
config=""
mode=0
test=0
c_compiler="/usr/bin/clang"
cxx_compiler="/usr/bin/clang++"
for var in "$@"
do
case $var in
-clean)
echo "Clean build."
rm -rf build/
rm lib/*.a
mkdir build/
exit 0
;;
-release)
mode=1
result_args+=" -DCMAKE_BUILD_TYPE:STRING=Release"
config="Release"
shift
;;
-debug)
mode=1
result_args+=" -DCMAKE_BUILD_TYPE:STRING=Debug"
config="Debug"
shift
;;
-asan)
result_args+=" -DASAN=ON"
shift
;;
-ubsan)
result_args+=" -DUBSAN=ON"
shift
;;
-mips)
result_args+=" -DARCH:STRING=MIPS"
shift
;;
-no-gc)
result_args+=" -DGCTYPE:STRING=NO_GC"
shift
;;
-shadow-stack-gc)
result_args+=" -DGCTYPE:STRING=LLVM_SHADOW_STACK"
shift
;;
-statepoint-example-gc)
result_args+=" -DGCTYPE:STRING=LLVM_STATEPOINT_EXAMPLE"
shift
;;
-test)
test=1
shift
;;
-llvm)
result_args+=" -DARCH:STRING=LLVM"
shift
;;
-myir)
result_args+=" -DARCH:STRING=MYIR"
shift
;;
-*|--*)
echo "Unknown option $var"
exit 1
;;
*)
;;
esac
done
if [ $mode -eq 0 ]; then
result_args+=" -DCMAKE_BUILD_TYPE:STRING=Release"
config="Release"
fi
cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE $result_args -DCMAKE_C_COMPILER:FILEPATH=$c_compiler -DCMAKE_CXX_COMPILER:FILEPATH=$cxx_compiler -H. -Bbuild -G "Unix Makefiles"
cmake --build build --config $config --target all -j 10 --
ln -sf build/compile_commands.json compile_commands.json
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/$PWD/bin/
echo "Added runtime lib to your LD_LIBRARY_PATH = " $LD_LIBRARY_PATH
elif [[ "$OSTYPE" == "darwin"* ]]; then
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:/$PWD/bin/
echo "Added runtime lib to your DYLD_LIBRARY_PATH = " $DYLD_LIBRARY_PATH
fi
if [ $test -eq 1 ]; then
ctest --test-dir build -C $config
fi