Skip to content

Commit

Permalink
*: add tirocks-sys and xtask (#1)
Browse files Browse the repository at this point in the history
The version of titan and rocksdb submodules are the same as master branch of rust-rocksdb. xtask crate is copied from grpc-rs. Build script is refactored.

Compared to rust-rocksdb, the main differences are:
1. Use cargo command and bindgen to maintain bindings just like grpc-rs:
    ```
    cargo xtask bindgen
    ```
2. Titan and rocksdb are maintained in one crate instead of two. Because compiling titan requires rocksdb, so it's impossible to publish a crate that only includes the source of titan. And compiling crocksdb also requires the source of titan. So it's easier to maintain to just put rocksdb and titan into one crate.
3. bindgen is completely removed from dependency tree unless we want to regenerate bindings. So compiling tirocks doesn't requires clang and llvm. It's safe for every platform to share the same bindings as all structs are opaque types and libc is used to cover the platform differences.
4. Released version of snappy-sys is used by default so we can publish tirocks in the future.

Signed-off-by: Jay Lee <[email protected]>
  • Loading branch information
BusyJay authored Jan 29, 2022
1 parent 55a0356 commit a15458c
Show file tree
Hide file tree
Showing 18 changed files with 15,511 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --manifest-path ./xtask/Cargo.toml --"
1 change: 1 addition & 0 deletions .clang-format
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

.vscode
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "titan-sys/titan"]
path = tirocks-sys/titan
url = https://github.com/tikv/titan.git
[submodule "tirocks-sys/rocksdb"]
path = tirocks-sys/rocksdb
url = https://github.com/tikv/rocksdb.git
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
members = [
"tirocks",
"tirocks-sys",
"xtask",
]

[patch.crates-io]
# Use cmake to build the binary, so it can be compiled on all supported platform.
snappy-sys = { git = "https://github.com/busyjay/rust-snappy.git", branch = "static-link" }
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
# tirocks
RocksDB bindings and wrappers in Rust

This library has been tested against RocksDB 6.4 on Linux and macOS.

Feedback and pull requests welcome! If a particular feature of RocksDB is important to you, please let us know by opening an issue, and we will prioritize it.

## Build

```
$ cargo xtask submodule # if you just cloned the repository
$ cargo build
```

Bindings are pre-generated, if the content in librocksdb_sys/crocksdb/crocksdb/c.h is updated, you may need to regenerate bindings:

```
$ cargo xtask bindgen
```

And running linting against C files:

```
$ cargo xtask clang-lint
```
43 changes: 43 additions & 0 deletions tirocks-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "tirocks-sys"
version = "0.1.0"
edition = "2021"
authors = ["The TiKV Project Developers"]
license = "Apache-2.0"
keywords = ["rocksdb", "bindings"]
links = "tirocks"

[dependencies]
# native library >=1.0.8
bzip2-sys = { version = "0.1.11", features = ["static"] }
libc = "0.2.11"
libz-sys = { version = "1.1", features = ["static"] }
openssl-sys = { version = "0.9.54", optional = true, features = ["vendored"] }
# native library >= 1.4.8
zstd-sys = "1.4.19"
lz4-sys = "1.9"
snappy-sys = "0.1"

[features]
default = []
encryption = ["openssl-sys"]
jemalloc = ["tikv-jemalloc-sys"]
sse = []
static-libcpp = []

# portable doesn't require static link, though it's meaningless
# when not using with static-link right now in this crate.
portable = []
# If this feature is enabled, bindings will be regenerated.
update-bindings = ["bindgen"]

[build-dependencies]
cc = "1.0"
cmake = "0.1"
# Because of rust-lang/cargo#5237, bindgen should not be upgraded until a minor or major release.
bindgen = { version = "0.57.0", default-features = false, optional = true, features = ["runtime"] }

[dependencies.tikv-jemalloc-sys]
version = "0.4.0"
optional = true
features = ["unprefixed_malloc_on_supported_platforms"]
Loading

0 comments on commit a15458c

Please sign in to comment.