-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sh
executable file
·93 lines (85 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
#!/bin/bash
# case insensitive for string comparison
shopt -s nocasematch
colorful_print() {
color_prefix="0;30"
case $1 in
"red")
color_prefix="0;31"
;;
"green")
color_prefix="0;32"
;;
"orange")
color_prefix="0;33"
;;
"blue")
color_prefix="0;34"
;;
"purple")
color_prefix="0;35"
;;
"cyan")
color_prefix="0;36"
;;
"lightgray")
color_prefix="0;37"
;;
"darkgray")
color_prefix="1;30"
;;
"lightred")
color_prefix="1;31"
;;
"lightgreen")
color_prefix="1;32"
;;
"yellow")
color_prefix="1;33"
;;
"lightblue")
color_prefix="1;34"
;;
"lightpurple")
color_prefix="1;35"
;;
"lightcyan")
color_prefix="1;36"
;;
"white")
color_prefix="1;37"
;;
esac;
echo -e "\e[${color_prefix}m $2 $3 $4 $5 $6 $7 $8 $9 \e[0m"
}
if [[ $# -lt 1 ]]; then
colorful_print orange "USAGE: $0 <Release|Debug|RelWithDebInfo|Benchmark|Clean> [USE_VERBS_API]"
exit -1
fi
if [[ $1 == "Clean" ]]; then
rm -rf build-* compile_commands.json
exit 0
fi
build_type=$1
if [ -z $CASCADE_INSTALL_PREFIX ]; then
install_prefix="/usr/local"
else
install_prefix=$CASCADE_INSTALL_PREFIX
fi
cmake_defs="-DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=${install_prefix} -Dpybind11_DIR=`pybind11-config --cmakedir`"
build_path="build-${build_type}"
if [[ $2 == "USE_VERBS_API" ]]; then
cmake_defs="${cmake_defs} -DUSE_VERBS_API=1"
fi
# begin building...
rm -rf ${install_prefix}/include/cascade ${install_prefix}/lib/libcascade* ${install_prefix}/lib/cmake/cascade
rm -rf ${build_path} 2>/dev/null
mkdir ${build_path}
cd ${build_path}
cmake ${cmake_defs} ..
NPROC=`nproc`
if [ $NPROC -lt 2 ]; then
NPROC=2
fi
make -j `expr $NPROC - 1` 2>err.log
cd ..