From f381c267100e99602260f3aa41661904179aee68 Mon Sep 17 00:00:00 2001 From: linxGnu Date: Fri, 1 Jan 2021 18:03:48 +0900 Subject: [PATCH] NO-ISSUE Update README and build script --- README.md | 69 +++++++++++-------------------------- docker/Dockerfile | 2 +- dynflag.go | 6 ---- static.go => non_builtin.go | 2 +- 4 files changed, 23 insertions(+), 56 deletions(-) delete mode 100644 dynflag.go rename static.go => non_builtin.go (76%) diff --git a/README.md b/README.md index 822a64e..b83ecc4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# grocksdb, a Go wrapper for RocksDB +# grocksdb, RocksDB wrapper for Go [![](https://github.com/linxGnu/grocksdb/workflows/CI/badge.svg)]() [![Go Report Card](https://goreportcard.com/badge/github.com/linxGnu/grocksdb)](https://goreportcard.com/report/github.com/linxGnu/grocksdb) @@ -10,74 +10,47 @@ The `LICENSE` still remains as upstream. Why I made a patched clone instead of PR: - Supports almost C API (unlike upstream). Catching up with latest version of Rocksdb as promise. -- Static build focused. - This fork contains `no defer` in codebase (my side project requires as less overhead as possible). This introduces loose convention of how/when to free c-mem, thus break the rule of [tecbot/gorocksdb](https://github.com/tecbot/gorocksdb). ## Install -### Default - Builtin Static (Linux only) +### Prerequisite -`grocksdb` contains built static version of `Rocksdb` with: -- gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39) +- librocksdb +- libsnappy +- libz +- liblz4 +- libzstd -You have to do nothing on your machine. Just install it like other go libraries: +Please follow this guide: https://github.com/facebook/rocksdb/blob/master/INSTALL.md to build above libs. -```bash -go get -u github.com/linxGnu/grocksdb +### Build -# Build your project with `builtin_static` tags: -go build -tags builtin_static -``` +After that, you can install `grocksdb` using the following command: -### Static lib (Linux only) + CGO_CFLAGS="-I/path/to/rocksdb/include" \ + CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lsnappy -llz4 -lzstd" \ + go get -u github.com/linxGnu/grocksdb -If you don't trust my builtin/want to build with your compiler/env: +## Usage -##### Prerequisite -- cmake 3.11+ -- make +See also: [doc](https://godoc.org/github.com/linxGnu/grocksdb) -##### Build +## Builtin Static -Make sure to install libraries for linking before making targets. +grocksdb bundles static version of RocksDB, build with env: +- centos 7 x86_64 +- gcc 4.8 -```bash -# You could find `Makefile` at root of repository +You could give it a try: -# build static libs -make ``` +go get -u github.com/linxGnu/grocksdb -Then, build your project with tags (same as above): - -``` go build -tags builtin_static ``` -### Existed Static lib - -In case, already have static-lib version of rocksdb, you could build your project with: - -``` -# don't use builtin static -go build -tags static -``` - -### Shared lib - -You'll need to build [RocksDB](https://github.com/facebook/rocksdb) v6.3.6+ on your machine. - -After that, you can install `grocksdb` using the following command: - - CGO_CFLAGS="-I/path/to/rocksdb/include" \ - CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lsnappy -llz4 -lzstd" \ - go get github.com/linxGnu/grocksdb - -## Usage - -See also: [doc](https://godoc.org/github.com/linxGnu/grocksdb) - ## API Support Almost C API, excepts: diff --git a/docker/Dockerfile b/docker/Dockerfile index c5e9100..3c6f4b4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,7 +20,7 @@ ENV CFLAGS='-fPIC -O3 -pipe' ENV CXXFLAGS='-fPIC -O3 -pipe' # install go -ENV GOLANG_PACKAGE go1.14.9.linux-amd64.tar.gz +ENV GOLANG_PACKAGE go1.15.6.linux-amd64.tar.gz RUN curl https://dl.google.com/go/${GOLANG_PACKAGE} -o ${GOLANG_PACKAGE} && \ tar -C /usr/local -xzf ${GOLANG_PACKAGE} && rm ${GOLANG_PACKAGE} diff --git a/dynflag.go b/dynflag.go deleted file mode 100644 index 6c93bb3..0000000 --- a/dynflag.go +++ /dev/null @@ -1,6 +0,0 @@ -// +build !static !builtin_static - -package grocksdb - -// #cgo LDFLAGS: -lrocksdb -pthread -lstdc++ -ldl -lm -lzstd -llz4 -lz -lsnappy -import "C" diff --git a/static.go b/non_builtin.go similarity index 76% rename from static.go rename to non_builtin.go index f12750c..70b220a 100644 --- a/static.go +++ b/non_builtin.go @@ -1,4 +1,4 @@ -// +build static !builtin_static +// +build !builtin_static package grocksdb