forked from milvus-io/knowhere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·121 lines (108 loc) · 2.61 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
#!/bin/bash
BUILD_OUTPUT_DIR="cmake_build"
BUILD_TYPE="Debug"
BUILD_UNITTEST="OFF"
INSTALL_PREFIX=$(pwd)/knowhere
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
while getopts "p:t:cglruzh" arg; do
case $arg in
c)
BUILD_COVERAGE="ON"
;;
g)
SUPPORT_GPU="ON"
;;
l)
RUN_CPPLINT="ON"
;;
p)
INSTALL_PREFIX=$OPTARG
;;
r)
MAKE_CLEAN="ON"
;;
t)
BUILD_TYPE=$OPTARG # BUILD_TYPE
;;
u)
echo "Build and run unittest cases" ;
BUILD_UNITTEST="ON";
;;
z)
SUPPORT_PROFILING="ON"
;;
h) # help
echo "
parameter:
-c: code coverage(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)
-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] [-u] [-z]
"
exit 0
;;
?)
echo "unknown argument"
exit 1
;;
esac
done
if [[ ! -d ${BUILD_OUTPUT_DIR} ]]; then
mkdir ${BUILD_OUTPUT_DIR}
fi
cd ${BUILD_OUTPUT_DIR}
if [[ ${MAKE_CLEAN} == "ON" ]]; then
echo "Running make clean in ${BUILD_OUTPUT_DIR} ..."
make clean
echo "Running make clean in thirdparty/faiss ..."
cd ../thirdparty/faiss
make clean
exit 0
fi
CMAKE_CMD="cmake -DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
-DMILVUS_ENABLE_PROFILING=${SUPPORT_PROFILING} \
-DKNOWHERE_GPU_VERSION=${SUPPORT_GPU} \
../"
echo ${CMAKE_CMD}
${CMAKE_CMD}
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