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

BUILD_TYPE="Debug"
BUILD_UNITTEST="off"
5
LICENSE_CHECK="OFF"
G
groot 已提交
6
INSTALL_PREFIX=$(pwd)/milvus
J
jinhai 已提交
7
MAKE_CLEAN="OFF"
G
groot 已提交
8

9
while getopts "p:t:uhlr" arg
G
groot 已提交
10 11 12 13 14 15 16 17 18
do
        case $arg in
             t)
                BUILD_TYPE=$OPTARG # BUILD_TYPE
                ;;
             u)
                echo "Build and run unittest cases" ;
                BUILD_UNITTEST="on";
                ;;
19 20 21
             p)
                INSTALL_PREFIX=$OPTARG
                ;;
22 23
             l)
                LICENSE_CHECK="ON"
X
xj.lin 已提交
24
                ;;
J
jinhai 已提交
25 26 27 28 29 30
             r)
                if [[ -d cmake_build ]]; then
                    rm ./cmake_build -r
                    MAKE_CLEAN="ON"
                fi
                ;;
G
groot 已提交
31 32 33 34 35 36
             h) # help
                echo "

parameter:
-t: build type
-u: building unit test options
37
-p: install prefix
38
-l: build license version
J
jinhai 已提交
39
-r: remove previous build directory
G
groot 已提交
40 41

usage:
J
jinhai 已提交
42
./build.sh -t \${BUILD_TYPE} [-u] [-h] [-g] [-r]
G
groot 已提交
43 44 45 46
                "
                exit 0
                ;;
             ?)
47
                echo "unknown argument"
G
groot 已提交
48 49 50 51 52
        exit 1
        ;;
        esac
done

J
jinhai 已提交
53 54 55
if [[ ! -d cmake_build ]]; then
	mkdir cmake_build
	MAKE_CLEAN="ON"
G
groot 已提交
56 57 58 59
fi

cd cmake_build

G
groot 已提交
60 61
CUDA_COMPILER=/usr/local/cuda/bin/nvcc

J
jinhai 已提交
62 63 64 65 66
if [[ ${MAKE_CLEAN} = "ON" ]]; then
    CMAKE_CMD="cmake -DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
    -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
    -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
    -DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
67
    -DCMAKE_LICENSE_CHECK=${LICENSE_CHECK} \
J
jinhai 已提交
68 69
    $@ ../"
    echo ${CMAKE_CMD}
G
groot 已提交
70

J
jinhai 已提交
71 72 73
    ${CMAKE_CMD}
    make clean
fi
G
groot 已提交
74

J
jinhai 已提交
75
make -j 4 || exit 1
G
groot 已提交
76

77
if [[ ${BUILD_TYPE} != "Debug" ]]; then
G
groot 已提交
78
    strip src/milvus_server
79 80
fi

81 82
make install