Skip to content

Commit

Permalink
NO-ISSUE Update README and build script
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu committed Jan 1, 2021
1 parent 8950fa6 commit f381c26
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 56 deletions.
69 changes: 21 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 0 additions & 6 deletions dynflag.go

This file was deleted.

2 changes: 1 addition & 1 deletion static.go → non_builtin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build static !builtin_static
// +build !builtin_static

package grocksdb

Expand Down

0 comments on commit f381c26

Please sign in to comment.