From 781122ece47f5bd55aed8661ace69099a67d49ab Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 15 May 2014 08:44:12 +0800 Subject: [PATCH] update readme, use remote gist to build leveled --- leveldb/build_deps.sh | 55 ------------------------------------------- leveldb/dev.sh | 12 ++++++++++ leveldb/readme.md | 11 +++++++-- 3 files changed, 21 insertions(+), 57 deletions(-) delete mode 100644 leveldb/build_deps.sh create mode 100644 leveldb/dev.sh diff --git a/leveldb/build_deps.sh b/leveldb/build_deps.sh deleted file mode 100644 index 968ad78..0000000 --- a/leveldb/build_deps.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -#refer https://github.com/norton/lets/blob/master/c_src/build_deps.sh - -SNAPPY_DIR=/usr/local/snappy -LEVELDB_DIR=/usr/local/leveldb - -ROOT_DIR=$(pwd) - -BUILD_DIR=/tmp/build_leveldb - -mkdir -p $BUILD_DIR - -cd $BUILD_DIR - -if [ ! -f $SNAPPY_DIR/lib/libsnappy.a ]; then - (git clone git@github.com:siddontang/snappy.git && \ - cd ./snappy && \ - ./configure --prefix=$SNAPPY_DIR && \ - make && \ - make install && \ - cd ..) -else - echo "skip install snappy" -fi - -cd $BUILD_DIR - -if [ ! -f $LEVELDB_DIR/lib/libleveldb.a ]; then - (git clone git@github.com:siddontang/leveldb.git && \ - cd ./leveldb && \ - echo "echo \"PLATFORM_CFLAGS+=-I$SNAPPY_DIR/include\" >> build_config.mk" >> build_detect_platform && - echo "echo \"PLATFORM_CXXFLAGS+=-I$SNAPPY_DIR/include\" >> build_config.mk" >> build_detect_platform && - echo "echo \"PLATFORM_LDFLAGS+=-L $SNAPPY_DIR/lib -lsnappy\" >> build_config.mk" >> build_detect_platform && - make SNAPPY=1 && \ - make && \ - mkdir -p $LEVELDB_DIR/include/leveldb && \ - install include/leveldb/*.h $LEVELDB_DIR/include/leveldb && \ - mkdir -p $LEVELDB_DIR/lib && \ - cp -f libleveldb.* $LEVELDB_DIR/lib &&\ - cd ..) -else - echo "skip install leveldb" -fi - -cd $ROOT_DIR - -export CGO_CFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include" -export CGO_CXXFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include" -export CGO_LDFLAGS="-L$LEVELDB_DIR/lib -L$SNAPPY_DIR/lib -lsnappy" -export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $SNAPPY_DIR/lib) -export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib) - - -go get github.com/jmhodges/levigo diff --git a/leveldb/dev.sh b/leveldb/dev.sh new file mode 100644 index 0000000..cdd826d --- /dev/null +++ b/leveldb/dev.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +SNAPPY_DIR=/usr/local/snappy +LEVELDB_DIR=/usr/local/leveldb + +export CGO_CFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include" +export CGO_CXXFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include" +export CGO_LDFLAGS="-L$LEVELDB_DIR/lib -L$SNAPPY_DIR/lib -lsnappy" +export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $SNAPPY_DIR/lib) +export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib) + +go get github.com/jmhodges/levigo diff --git a/leveldb/readme.md b/leveldb/readme.md index bc7e4f0..fd68753 100644 --- a/leveldb/readme.md +++ b/leveldb/readme.md @@ -2,10 +2,17 @@ a leveldb wrapper for levigo simplify use leveldb in go +# Build leveldb + +see [https://gist.github.com/siddontang/dfbc835e06e47d0f6297](https://gist.github.com/siddontang/dfbc835e06e47d0f6297) for build leveldb + # Install -+ download leveldb and snappy source, uncompress and set source directory in build_deps.sh -+ . ./build_deps.sh +you must first set CGO_CFLAGS, CGO_LDFLAGS to your leveldb and snappy directory. + +dev.sh may help you: + + . ./dev.sh # Performance