2021-01-11 18:35:54 +08:00
#!/bin/bash
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
DIR = $( cd -P $( dirname $SOURCE ) && pwd )
# echo $DIR
2021-01-14 15:12:08 +08:00
CMAKE_BUILD = ${ DIR } /../cwrapper_rocksdb_build
OUTPUT_LIB = ${ DIR } /../internal/kv/rocksdb/cwrapper/output
2021-01-11 18:35:54 +08:00
SRC_DIR = ${ DIR } /../internal/kv/rocksdb/cwrapper
2021-01-14 15:12:08 +08:00
if [ ! -d ${ CMAKE_BUILD } ] ; then
mkdir ${ CMAKE_BUILD }
fi
2021-01-11 18:35:54 +08:00
2021-01-14 15:12:08 +08:00
if [ ! -d ${ OUTPUT_LIB } ] ; then
mkdir ${ OUTPUT_LIB }
2021-01-11 18:35:54 +08:00
fi
BUILD_TYPE = "Debug"
2021-01-14 15:12:08 +08:00
CUSTOM_THIRDPARTY_PATH = ""
2021-01-11 18:35:54 +08:00
2021-01-14 15:12:08 +08:00
while getopts "t:h:f:" arg; do
2021-01-11 18:35:54 +08:00
case $arg in
2021-01-14 15:12:08 +08:00
f)
CUSTOM_THIRDPARTY_PATH = $OPTARG
; ;
2021-01-11 18:35:54 +08:00
t)
BUILD_TYPE = $OPTARG # BUILD_TYPE
; ;
h) # help
echo " -t: build type(default: Debug)
2021-01-14 15:12:08 +08:00
-f: custom thirdparty path( default: "" )
2021-01-11 18:35:54 +08:00
-h: help
"
exit 0
; ;
?)
echo "ERROR! unknown argument"
exit 1
; ;
esac
done
echo "BUILD_TYPE: " $BUILD_TYPE
2021-01-14 15:12:08 +08:00
echo "CUSTOM_THIRDPARTY_PATH: " $CUSTOM_THIRDPARTY_PATH
2021-01-11 18:35:54 +08:00
2021-01-14 15:12:08 +08:00
pushd ${ CMAKE_BUILD }
2021-01-11 18:35:54 +08:00
CMAKE_CMD = " cmake \
2021-01-14 15:12:08 +08:00
-DCMAKE_BUILD_TYPE= ${ BUILD_TYPE }
-DCMAKE_INSTALL_PREFIX= ${ OUTPUT_LIB } \
-DCUSTOM_THIRDPARTY_DOWNLOAD_PATH= ${ CUSTOM_THIRDPARTY_PATH } ${ SRC_DIR } "
2021-01-11 18:35:54 +08:00
${ CMAKE_CMD }
echo ${ CMAKE_CMD }
if [ [ ! ${ jobs +1 } ] ] ; then
jobs = $( nproc)
fi
make -j ${ jobs }
2021-07-08 15:43:45 +08:00
go env -w CGO_CFLAGS = " -I ${ OUTPUT_LIB } /include "
if [ -f " ${ OUTPUT_LIB } /lib/librocksdb.a " ] ; then
go env -w CGO_LDFLAGS = " -L ${ OUTPUT_LIB } /lib -l:librocksdb.a -lstdc++ -lm -lz "
else
go env -w CGO_LDFLAGS = " -L ${ OUTPUT_LIB } /lib64 -l:librocksdb.a -lstdc++ -lm -lz "
fi
go get github.com/tecbot/gorocksdb