ledisdb/dev.sh

65 lines
1.8 KiB
Bash
Raw Normal View History

2014-05-09 10:49:22 +04:00
#!/bin/bash
export VTTOP=$(pwd)
export VTROOT="${VTROOT:-${VTTOP/\/src\/github.com\/siddontang\/ledisdb/}}"
# VTTOP sanity check
if [[ "$VTTOP" == "${VTTOP/\/src\/github.com\/siddontang\/ledisdb/}" ]]; then
echo "WARNING: VTTOP($VTTOP) does not contain src/github.com/siddontang/ledisdb"
exit 1
fi
#default snappy and leveldb install path
#you may change yourself
2014-07-25 20:46:03 +04:00
SNAPPY_DIR=/usr/local/snappy
LEVELDB_DIR=/usr/local/leveldb
ROCKSDB_DIR=
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
}
export GOPATH=$(add_path $GOPATH $VTROOT)
2014-07-25 20:46:03 +04:00
# check snappy
if [ -f $SNAPPY_DIR/lib/libsnappy.a ]; then
CGO_CFLAGS+="-I$SNAPPY_DIR/include"
CGO_CXXFLAGS+="-I$SNAPPY_DIR/include"
CGO_LDFLAGS+="-L$SNAPPY_DIR/lib -lsnappy"
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
if [ -f $LEVELDB_DIR/lib/libleveldb.a ]; then
CGO_CFLAGS+="-I$LEVELDB_DIR/include"
CGO_CXXFLAGS+="-I$LEVELDB_DIR/include"
CGO_LDFLAGS+="-L$LEVELDB_DIR/lib -lleveldb"
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $LEVELDB_DIR/lib)
GO_BUILD_TAGS+="leveldb"
fi
2014-07-25 20:46:03 +04:00
# check rocksdb
if [ -f $ROCKSDB_DIR/lib/libleveldb.a ]; then
CGO_CFLAGS+="-I$ROCKSDB_DIR/include"
CGO_CXXFLAGS+="-I$ROCKSDB_DIR/include"
CGO_LDFLAGS+="-L$ROCKSDB_DIR/lib -lleveldb"
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $ROCKSDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $ROCKSDB_DIR/lib)
GO_BUILD_TAGS+="rocksdb"
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