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

BUILD_TYPE="Debug"
BUILD_UNITTEST="off"
X
xj.lin 已提交
5
BUILD_GPU="OFF"
6
INSTALL_PREFIX=$(pwd)/megasearch
J
jinhai 已提交
7
MAKE_CLEAN="OFF"
G
groot 已提交
8

J
jinhai 已提交
9
while getopts "p:t:uhgr" 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
                ;;
X
xj.lin 已提交
22 23 24
             g)
                BUILD_GPU="ON"
                ;;
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
J
jinhai 已提交
38 39
-g: build GPU version
-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 67 68 69
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} \
    -DGPU_VERSION=${BUILD_GPU} \
    $@ ../"
    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 78 79 80
if [[ ${BUILD_TYPE} != "Debug" ]]; then
    strip src/vecwise_server
fi

81 82
make install