forked from milvus-io/knowhere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·150 lines (135 loc) · 3.45 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
# Exit immediately for non zero status
set -e
UNAME="$(uname -s)"
case "${UNAME}" in
Linux*) MACHINE=Linux;;
Darwin*) MACHINE=Mac;;
CYGWIN*) MACHINE=Cygwin;;
MINGW*) MACHINE=MinGw;;
*) MACHINE="UNKNOWN:${UNAME}"
esac
BUILD_DIR="cmake_build"
OUTPUT_DIR="output"
BUILD_TYPE="Debug"
BUILD_UNITTEST="OFF"
INSTALL_PREFIX=$(pwd)/${OUTPUT_DIR}
MAKE_CLEAN="OFF"
BUILD_COVERAGE="OFF"
SUPPORT_PROFILING="OFF"
RUN_CPPLINT="OFF"
CUDA_COMPILER=/usr/local/cuda/bin/nvcc
SUPPORT_GPU="OFF" #defaults to CPU version
KNOWHERE_WITH_DISKANN="OFF"
ENABLE_SANITIZER="OFF"
BUILD_BENCHMARK="OFF"
while getopts "p:t:bcdglrsuzh" arg; do
case $arg in
b)
BUILD_BENCHMARK="ON" ;;
c)
BUILD_COVERAGE="ON" ;;
d)
KNOWHERE_WITH_DISKANN="ON";;
g)
SUPPORT_GPU="ON" ;;
l)
RUN_CPPLINT="ON" ;;
p)
INSTALL_PREFIX=$OPTARG ;;
r)
MAKE_CLEAN="ON" ;;
s)
ENABLE_SANITIZER="ON";;
t)
BUILD_TYPE=$OPTARG ;;
u)
echo "Build and run unittest cases"
BUILD_UNITTEST="ON" ;;
z)
SUPPORT_PROFILING="ON" ;;
h) # help
echo "
parameter:
-b: build benchmark(default: OFF)
-c: code coverage(default: OFF)
-d: support DiskANN(default: OFF)
-g: build GPU version(default: OFF)
-l: run cpplint, clang-format and clang-tidy(default: OFF)
-p: install prefix(default: $(pwd)/knowhere)
-r: remove previous build directory(default: OFF)
-s: run sanitizer check (default: OFF)
-t: build type(default: Debug)
-u: building unit test options(default: OFF)
-z: support CPU profiling(default: OFF)
-h: help
usage:
./build.sh -t \${BUILD_TYPE} [-c] [-g] [-l] [-r] [-s] [-u] [-z]
"
exit 0 ;;
?)
echo "unknown argument"
exit 1 ;;
esac
done
if [[ ${MAKE_CLEAN} == "ON" ]]; then
echo "Remove ${BUILD_DIR} ${OUTPUT_DIR} ..."
rm -rf ${BUILD_DIR} ${OUTPUT_DIR}
echo "Clean faiss ..."
cd thirdparty/faiss
rm -rf CMakeFiles _deps CMakeCache.txt
cd ../../
echo "Cleaning DiskANN ..."
cd thirdparty/DiskANN
rm -rf build/
cd ../../
exit 0
fi
if [[ ! -d ${BUILD_DIR} ]]; then
mkdir ${BUILD_DIR}
fi
cd ${BUILD_DIR}
CMAKE_CMD="cmake -DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_COVERAGE=${BUILD_COVERAGE} \
-DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
-DENABLE_PROFILING=${SUPPORT_PROFILING} \
-DKNOWHERE_GPU_VERSION=${SUPPORT_GPU} \
-DENABLE_SANITIZER=${ENABLE_SANITIZER} \
-DKNOWHERE_WITH_DISKANN=${KNOWHERE_WITH_DISKANN} \
-DBUILD_BENCHMARK=${BUILD_BENCHMARK} \
../"
echo ${CMAKE_CMD}
if [[ "$MACHINE" == "MinGw" ]] ; then
# force makefile for MinGW
${CMAKE_CMD} -G "MSYS Makefiles"
else
${CMAKE_CMD}
fi
if [[ ${RUN_CPPLINT} == "ON" ]]; then
# cpplint check
make lint-knowhere
if [ $? -ne 0 ]; then
echo "ERROR! cpplint check failed"
exit 1
fi
echo "cpplint check passed!"
# clang-format check
make check-clang-format-knowhere
if [ $? -ne 0 ]; then
echo "ERROR! clang-format check failed"
exit 1
fi
echo "clang-format check passed!"
# clang-tidy check
# make check-clang-tidy-knowhere
# if [ $? -ne 0 ]; then
# echo "ERROR! clang-tidy check failed"
# exit 1
# fi
# echo "clang-tidy check passed!"
else
# compile and build
make -j 8 install || exit 1
fi