ledisdb/dev.sh

79 lines
2.4 KiB
Bash
Raw Normal View History

2014-05-09 10:49:22 +04:00
#!/bin/bash
2014-07-26 14:39:54 +04:00
export LEDISTOP=$(pwd)
export LEDISROOT="${LEDISROOT:-${LEDISTOP/\/src\/github.com\/ledisdb\/ledisdb/}}"
2014-07-26 14:39:54 +04:00
# LEDISTOP sanity check
if [[ "$LEDISTOP" == "${LEDISTOP/\/src\/github.com\/ledisdb\/ledisdb/}" ]]; then
echo "WARNING: LEDISTOP($LEDISTOP) does not contain src/github.com/ledisdb/ledisdb"
false
2014-05-09 10:49:22 +04:00
fi
#default snappy and leveldb install path
#you may change yourself
2015-12-19 22:30:26 +03:00
HOMEBREW_PREFIX=$(type brew >/dev/null 2>&1 && brew --prefix 2>/dev/null)
2015-10-05 07:03:01 +03:00
if [[ ! -z "$HOMEBREW_PREFIX" ]]; then
SNAPPY_DIR=$HOMEBREW_PREFIX/opt/snappy
LEVELDB_DIR=$HOMEBREW_PREFIX/opt/leveldb
ROCKSDB_DIR=$HOMEBREW_PREFIX/opt/rocksdb
else
SNAPPY_DIR=/usr/local/snappy
LEVELDB_DIR=/usr/local/leveldb
ROCKSDB_DIR=/usr/local/rocksdb
fi
2014-05-09 10:49:22 +04:00
function add_path()
{
# $1 path variable
# $2 path to add
if [ -d "$2" ] && [[ ":$1:" != *":$2:"* ]]; then
echo "$1:$2"
else
echo "$1"
fi
}
2014-07-26 14:39:54 +04:00
export GOPATH=$(add_path $GOPATH $LEDISROOT)
2014-07-26 05:22:09 +04:00
2014-07-26 14:39:54 +04:00
GO_BUILD_TAGS=
CGO_CFLAGS=
CGO_CXXFLAGS=
CGO_LDFLAGS=
2014-07-28 08:46:17 +04:00
# check dependent libray, now we only check simply, maybe later add proper checking way.
2014-07-25 20:46:03 +04:00
# check snappy
2014-08-02 08:59:33 +04:00
if [ -f $SNAPPY_DIR/include/snappy.h ]; then
2014-07-26 05:22:09 +04:00
CGO_CFLAGS="$CGO_CFLAGS -I$SNAPPY_DIR/include"
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$SNAPPY_DIR/include"
CGO_LDFLAGS="$CGO_LDFLAGS -L$SNAPPY_DIR/lib -lsnappy"
2014-07-25 20:46:03 +04:00
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $SNAPPY_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $SNAPPY_DIR/lib)
fi
# check leveldb
2014-07-28 08:46:17 +04:00
if [ -f $LEVELDB_DIR/include/leveldb/c.h ]; then
2014-07-26 05:22:09 +04:00
CGO_CFLAGS="$CGO_CFLAGS -I$LEVELDB_DIR/include"
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$LEVELDB_DIR/include"
CGO_LDFLAGS="$CGO_LDFLAGS -L$LEVELDB_DIR/lib -lleveldb"
2014-07-25 20:46:03 +04:00
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $LEVELDB_DIR/lib)
2014-07-26 05:22:09 +04:00
GO_BUILD_TAGS="$GO_BUILD_TAGS leveldb"
2014-07-25 20:46:03 +04:00
fi
2014-07-25 20:46:03 +04:00
# check rocksdb
2014-07-28 08:46:17 +04:00
if [ -f $ROCKSDB_DIR/include/rocksdb/c.h ]; then
2014-07-26 05:22:09 +04:00
CGO_CFLAGS="$CGO_CFLAGS -I$ROCKSDB_DIR/include"
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$ROCKSDB_DIR/include"
2014-07-26 14:39:54 +04:00
CGO_LDFLAGS="$CGO_LDFLAGS -L$ROCKSDB_DIR/lib -lrocksdb"
2014-07-25 20:46:03 +04:00
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $ROCKSDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $ROCKSDB_DIR/lib)
2014-07-26 05:22:09 +04:00
GO_BUILD_TAGS="$GO_BUILD_TAGS rocksdb"
2014-07-25 20:46:03 +04:00
fi
2014-05-09 10:49:22 +04:00
2014-07-25 20:46:03 +04:00
export CGO_CFLAGS
export CGO_CXXFLAGS
export CGO_LDFLAGS
export LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
export GO_BUILD_TAGS