2019-11-06 09:14:31 +00:00
#!/bin/bash
2019-11-06 09:55:30 +00:00
set -e
2019-11-06 09:14:31 +00:00
SOURCE = " ${ BASH_SOURCE [0] } "
while [ -h " $SOURCE " ] ; do # resolve $SOURCE until the file is no longer a symlink
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
SOURCE = " $( readlink " $SOURCE " ) "
[ [ $SOURCE != /* ] ] && SOURCE = " $DIR / $SOURCE " # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPTS_DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
MILVUS_CORE_DIR = " ${ SCRIPTS_DIR } /../../core "
CORE_BUILD_DIR = " ${ MILVUS_CORE_DIR } /cmake_build "
BUILD_TYPE = "Debug"
BUILD_UNITTEST = "OFF"
INSTALL_PREFIX = "/opt/milvus"
2019-11-13 08:36:40 +00:00
FAISS_ROOT = ""
2019-11-20 06:19:31 +00:00
CUSTOMIZATION = "OFF" # default use origin faiss
2019-11-06 09:14:31 +00:00
BUILD_COVERAGE = "OFF"
USE_JFROG_CACHE = "OFF"
RUN_CPPLINT = "OFF"
2019-11-13 05:38:59 +00:00
GPU_VERSION = "OFF"
2019-11-11 11:48:29 +00:00
WITH_MKL = "OFF"
2019-11-06 09:14:31 +00:00
CUDA_COMPILER = /usr/local/cuda/bin/nvcc
2019-11-20 06:19:31 +00:00
while getopts "o:t:b:f:gxulcjmh" arg
2019-11-06 09:14:31 +00:00
do
case $arg in
o)
INSTALL_PREFIX = $OPTARG
; ;
t)
BUILD_TYPE = $OPTARG # BUILD_TYPE
; ;
b)
CORE_BUILD_DIR = $OPTARG # CORE_BUILD_DIR
; ;
2019-11-13 08:36:40 +00:00
f)
FAISS_ROOT = $OPTARG # FAISS ROOT PATH
; ;
2019-11-07 02:58:00 +00:00
g)
2019-11-13 05:38:59 +00:00
GPU_VERSION = "ON" ;
2019-11-07 02:58:00 +00:00
; ;
2019-11-20 06:19:31 +00:00
x)
CUSTOMIZATION = "ON" ;
; ;
2019-11-06 09:14:31 +00:00
u)
echo "Build and run unittest cases" ;
BUILD_UNITTEST = "ON" ;
; ;
l)
RUN_CPPLINT = "ON"
; ;
c)
BUILD_COVERAGE = "ON"
; ;
j)
USE_JFROG_CACHE = "ON"
; ;
2019-11-11 11:48:29 +00:00
m)
WITH_MKL = "ON"
; ;
2019-11-06 09:14:31 +00:00
h) # help
echo "
parameter:
-o: install prefix( default: /opt/milvus)
-t: build type( default: Debug)
-b: core code build directory
2019-11-13 08:36:40 +00:00
-f: faiss root path
2019-11-07 02:58:00 +00:00
-g: gpu version
2019-11-20 06:19:31 +00:00
-x: milvus customization ( default: OFF)
2019-11-06 09:14:31 +00:00
-u: building unit test options( default: OFF)
-l: run cpplint, clang-format and clang-tidy( default: OFF)
-c: code coverage( default: OFF)
-j: use jfrog cache build directory( default: OFF)
2019-11-11 11:48:29 +00:00
-m: build with MKL( default: OFF)
2019-11-06 09:14:31 +00:00
-h: help
usage:
2019-11-20 06:19:31 +00:00
./build.sh -o \$ { INSTALL_PREFIX} -t \$ { BUILD_TYPE} -b \$ { CORE_BUILD_DIR} -f \$ { FAISS_ROOT} [ -g] [ -x] [ -u] [ -l] [ -c] [ -j] [ -m] [ -h]
2019-11-06 09:14:31 +00:00
"
exit 0
; ;
?)
echo "ERROR! unknown argument"
exit 1
; ;
esac
done
if [ [ ! -d ${ CORE_BUILD_DIR } ] ] ; then
mkdir ${ CORE_BUILD_DIR }
fi
2019-11-13 05:38:59 +00:00
cd ${ CORE_BUILD_DIR }
2019-11-06 09:14:31 +00:00
CMAKE_CMD = " cmake \
-DCMAKE_INSTALL_PREFIX= ${ INSTALL_PREFIX }
-DCMAKE_BUILD_TYPE= ${ BUILD_TYPE } \
-DCMAKE_CUDA_COMPILER= ${ CUDA_COMPILER } \
2019-11-13 05:38:59 +00:00
-DMILVUS_GPU_VERSION= ${ GPU_VERSION } \
2019-11-20 06:19:31 +00:00
-DCUSTOMIZATION= ${ CUSTOMIZATION } \
2019-11-06 09:14:31 +00:00
-DBUILD_UNIT_TEST= ${ BUILD_UNITTEST } \
-DBUILD_COVERAGE= ${ BUILD_COVERAGE } \
-DUSE_JFROG_CACHE= ${ USE_JFROG_CACHE } \
2019-11-13 08:36:40 +00:00
-DFAISS_ROOT= ${ FAISS_ROOT } \
-DFAISS_WITH_MKL= ${ WITH_MKL } \
2019-11-12 03:12:03 +00:00
-DArrow_SOURCE= AUTO \
2019-11-13 08:36:40 +00:00
-DFAISS_SOURCE= AUTO \
2019-11-06 09:14:31 +00:00
${ MILVUS_CORE_DIR } "
echo ${ CMAKE_CMD }
${ CMAKE_CMD }
2019-11-13 05:38:59 +00:00
if [ [ ${ RUN_CPPLINT } = = "ON" ] ] ; then
# cpplint check
make lint
if [ $? -ne 0 ] ; then
echo "ERROR! cpplint check failed"
exit 1
fi
echo "cpplint check passed!"
# clang-format check
make check-clang-format
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
# if [ $? -ne 0 ]; then
# echo "ERROR! clang-tidy check failed"
# rm -f CMakeCache.txt
# exit 1
# fi
# echo "clang-tidy check passed!"
fi
2019-11-06 09:55:30 +00:00
# compile and build
make -j8 || exit 1
make install || exit 1