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

BUILD_TYPE="Debug"
BUILD_UNITTEST="off"
5
INSTALL_PREFIX=$(pwd)/megasearch
G
groot 已提交
6 7 8 9 10 11 12 13 14 15 16

while getopts "p:t:uh" arg
do
        case $arg in
             t)
                BUILD_TYPE=$OPTARG # BUILD_TYPE
                ;;
             u)
                echo "Build and run unittest cases" ;
                BUILD_UNITTEST="on";
                ;;
17 18 19
             p)
                INSTALL_PREFIX=$OPTARG
                ;;
G
groot 已提交
20 21 22 23 24 25
             h) # help
                echo "

parameter:
-t: build type
-u: building unit test options
26
-p: install prefix
G
groot 已提交
27 28 29 30 31 32 33

usage:
./build.sh -t \${BUILD_TYPE} [-u] [-h]
                "
                exit 0
                ;;
             ?)
34
                echo "unknown argument"
G
groot 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47
        exit 1
        ;;
        esac
done

if [[ -d cmake_build ]]; then
	rm cmake_build -r
fi

rm -rf ./cmake_build
mkdir cmake_build
cd cmake_build

G
groot 已提交
48 49
CUDA_COMPILER=/usr/local/cuda/bin/nvcc

G
groot 已提交
50
CMAKE_CMD="cmake -DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
51
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
G
groot 已提交
52
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
G
groot 已提交
53
-DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
G
groot 已提交
54 55 56 57 58 59 60
$@ ../"
echo ${CMAKE_CMD}

${CMAKE_CMD}

make clean && make -j || exit 1

61 62 63 64
if [[ ${BUILD_TYPE} != "Debug" ]]; then
    strip src/vecwise_server
fi

65 66
make install