build.sh 3.1 KB
Newer Older
G
groot 已提交
1 2 3
#!/bin/bash

BUILD_TYPE="Debug"
G
groot 已提交
4
BUILD_UNITTEST="OFF"
G
groot 已提交
5
INSTALL_PREFIX=$(pwd)/milvus
J
jinhai 已提交
6
MAKE_CLEAN="OFF"
Z
zhenxiang.li 已提交
7
BUILD_COVERAGE="OFF"
G
groot 已提交
8
DB_PATH="/opt/milvus"
Y
yudong.cai 已提交
9
PROFILING="OFF"
Q
quicksilver 已提交
10
USE_JFROG_CACHE="OFF"
11 12
RUN_CPPLINT="OFF"
CUDA_COMPILER=/usr/local/cuda/bin/nvcc
G
groot 已提交
13

14
while getopts "p:d:t:ulrcgjh" arg
G
groot 已提交
15 16
do
        case $arg in
17 18 19 20 21 22
             p)
                INSTALL_PREFIX=$OPTARG
                ;;
             d)
                DB_PATH=$OPTARG
                ;;
G
groot 已提交
23 24 25 26 27
             t)
                BUILD_TYPE=$OPTARG # BUILD_TYPE
                ;;
             u)
                echo "Build and run unittest cases" ;
G
groot 已提交
28
                BUILD_UNITTEST="ON";
G
groot 已提交
29
                ;;
30 31
             l)
                RUN_CPPLINT="ON"
G
groot 已提交
32
                ;;
J
jinhai 已提交
33 34 35 36 37 38
             r)
                if [[ -d cmake_build ]]; then
                    rm ./cmake_build -r
                    MAKE_CLEAN="ON"
                fi
                ;;
Z
zhenxiang.li 已提交
39 40 41
             c)
                BUILD_COVERAGE="ON"
                ;;
Y
yudong.cai 已提交
42 43 44
             g)
                PROFILING="ON"
                ;;
Q
quicksilver 已提交
45 46 47
             j)
                USE_JFROG_CACHE="ON"
                ;;
G
groot 已提交
48 49 50 51
             h) # help
                echo "

parameter:
G
groot 已提交
52 53
-p: install prefix(default: $(pwd)/milvus)
-d: db path(default: /opt/milvus)
54 55 56
-t: build type(default: Debug)
-u: building unit test options(default: OFF)
-l: run cpplint, clang-format and clang-tidy(default: OFF)
G
groot 已提交
57 58
-r: remove previous build directory(default: OFF)
-c: code coverage(default: OFF)
Y
yudong.cai 已提交
59
-g: profiling(default: OFF)
60 61
-j: use jfrog cache build directory(default: OFF)
-h: help
G
groot 已提交
62 63

usage:
64
./build.sh -p \${INSTALL_PREFIX} -t \${BUILD_TYPE} [-u] [-l] [-r] [-c] [-g] [-j] [-h]
G
groot 已提交
65 66 67 68
                "
                exit 0
                ;;
             ?)
69
                echo "ERROR! unknown argument"
G
groot 已提交
70 71 72 73 74
        exit 1
        ;;
        esac
done

J
jinhai 已提交
75
if [[ ! -d cmake_build ]]; then
76
    mkdir cmake_build
G
groot 已提交
77 78 79
fi

cd cmake_build
G
groot 已提交
80

81 82 83 84 85 86 87 88 89 90 91 92
CMAKE_CMD="cmake \
-DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
-DBUILD_COVERAGE=${BUILD_COVERAGE} \
-DMILVUS_DB_PATH=${DB_PATH} \
-DMILVUS_ENABLE_PROFILING=${PROFILING} \
-DUSE_JFROG_CACHE=${USE_JFROG_CACHE} \
../"
echo ${CMAKE_CMD}
${CMAKE_CMD}
G
groot 已提交
93

Z
zhenxiang.li 已提交
94
if [[ ${MAKE_CLEAN} == "ON" ]]; then
J
jinhai 已提交
95 96
    make clean
fi
G
groot 已提交
97

98 99 100 101
if [[ ${RUN_CPPLINT} == "ON" ]]; then
    # cpplint check
    make lint
    if [ $? -ne 0 ]; then
G
groot 已提交
102
        echo "ERROR! cpplint check failed"
103 104
        exit 1
    fi
G
groot 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    echo "cpplint check pass!"

#    # clang-format check
#    make check-clang-format
#    if [ $? -ne 0 ]; then
#        echo "ERROR! clang-format check failed"
#        exit 1
#    fi
#    echo "clang-format check pass!"
#
#    # clang-tidy check
#    make check-clang-tidy
#    if [ $? -ne 0 ]; then
#        echo "ERROR! clang-tidy check failed"
#        exit 1
#    fi
#    echo "clang-tidy check pass!"
122 123 124
else
    # compile and build
    make -j 4 || exit 1
G
groot 已提交
125

126 127 128 129
    # strip binary symbol
    if [[ ${BUILD_TYPE} != "Debug" ]]; then
        strip src/milvus_server
    fi
130

131
    make install || exit 1
132

133 134 135 136 137 138 139
    # evaluate code coverage
    if [[ ${BUILD_COVERAGE} == "ON" ]]; then
        cd -
        bash `pwd`/coverage.sh
        cd -
    fi
fi