Compression algorthms are now enabled by crate features...

master
Jordan Terrell 6 years ago
parent b56881e5d6
commit 16a49d9706
  1. 8
      Cargo.toml
  2. 11
      README.md
  3. 6
      librocksdb-sys/Cargo.toml
  4. 49
      librocksdb-sys/build.rs

@ -14,8 +14,14 @@ exclude = [
]
[features]
default = []
default = ["snappy", "lz4", "zstd", "zlib", "bzip2"]
valgrind = []
snappy = ["librocksdb-sys/snappy"]
lz4 = ["librocksdb-sys/lz4"]
zstd = ["librocksdb-sys/zstd"]
zlib = ["librocksdb-sys/zlib"]
bzip2 = ["librocksdb-sys/bzip2"]
[dependencies]
libc = "0.2"

@ -6,6 +6,15 @@ rust-rocksdb
Feedback and pull requests welcome! If a particular feature of RocksDB is important to you, please let me know by opening an issue, and I'll prioritize it.
This binding is statically linked with a specific version of RocksDB. If you want to build it yourself, make sure you've also cloned the RocksDB and Snappy submodules:
This binding is statically linked with a specific version of RocksDB. If you want to build it yourself, make sure you've also cloned the RocksDB and compression submodules:
git submodule update --init --recursive
## Compression Support
By default, support for the [Snappy](https://github.com/google/snappy), [LZ4](https://github.com/lz4/lz4), [Zstd](https://github.com/facebook/zstd), [Zlib](https://zlib.net), and [Bzip2](http://www.bzip.org) compression is enabled through crate features. If support for all of these compression algorithms is not needed, default features can be disabled and specific compression algorithms can be enabled. For example, to enable only LZ4 compression support, make these changes to your Cargo.toml:
```
[dependencies.rocksdb]
default-features = false
features = ["lz4"]
```

@ -14,6 +14,12 @@ links = "rocksdb"
[features]
default = [ "static" ]
static = []
snappy = []
lz4 = []
zstd = []
zlib = []
bzip2 = []
[dependencies]
libc = "0.2"

@ -49,20 +49,35 @@ fn build_rocksdb() {
config.include("rocksdb/include/");
config.include("rocksdb/");
config.include("rocksdb/third-party/gtest-1.7.0/fused-src/");
config.include("snappy/");
config.include("lz4/lib/");
config.include("zstd/lib/");
config.include("zstd/lib/dictBuilder/");
config.include("zlib/");
config.include("bzip2/");
config.include(".");
if cfg!(feature = "snappy") {
config.define("SNAPPY", Some("1"));
config.include("snappy/");
}
if cfg!(feature = "lz4") {
config.define("LZ4", Some("1"));
config.include("lz4/lib/");
}
if cfg!(feature = "zstd") {
config.define("ZSTD", Some("1"));
config.include("zstd/lib/");
config.include("zstd/lib/dictBuilder/");
}
if cfg!(feature = "zlib") {
config.define("ZLIB", Some("1"));
config.include("zlib/");
}
if cfg!(feature = "bzip2") {
config.define("BZIP2", Some("1"));
config.include("bzip2/");
}
config.include(".");
config.define("NDEBUG", Some("1"));
config.define("SNAPPY", Some("1"));
config.define("LZ4", Some("1"));
config.define("ZSTD", Some("1"));
config.define("ZLIB", Some("1"));
config.define("BZIP2", Some("1"));
let mut lib_sources = include_str!("rocksdb_lib_sources.txt")
.split(" ")
@ -281,19 +296,19 @@ fn main() {
if !try_to_find_and_link_lib("ROCKSDB") {
build_rocksdb();
}
if !try_to_find_and_link_lib("SNAPPY") {
if cfg!(feature = "snappy") && !try_to_find_and_link_lib("SNAPPY") {
build_snappy();
}
if !try_to_find_and_link_lib("LZ4") {
if cfg!(feature = "lz4") && !try_to_find_and_link_lib("LZ4") {
build_lz4();
}
if !try_to_find_and_link_lib("ZSTD") {
if cfg!(feature = "zstd") && !try_to_find_and_link_lib("ZSTD") {
build_zstd();
}
if !try_to_find_and_link_lib("ZLIB") {
if cfg!(feature = "zlib") && !try_to_find_and_link_lib("ZLIB") {
build_zlib();
}
if !try_to_find_and_link_lib("BZIP2") {
if cfg!(feature = "bzip2") && !try_to_find_and_link_lib("BZIP2") {
build_bzip2();
}
}

Loading…
Cancel
Save