From f54deaf1e075d4784d235d503c92672722bd2dae Mon Sep 17 00:00:00 2001 From: Jordan Terrell Date: Tue, 21 Aug 2018 04:43:25 -0500 Subject: [PATCH] Adding LZ4 compression support and updated Snappy version to same version targeted by RocksDb... --- .gitmodules | 3 +++ librocksdb-sys/build.rs | 29 +++++++++++++++++++++++++++++ librocksdb-sys/lz4 | 1 + librocksdb-sys/snappy | 2 +- librocksdb-sys/zstd | 1 + 5 files changed, 35 insertions(+), 1 deletion(-) create mode 160000 librocksdb-sys/lz4 create mode 160000 librocksdb-sys/zstd diff --git a/.gitmodules b/.gitmodules index 2c818bd..0c44d00 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "rocksdb_sys/rocksdb"] path = librocksdb-sys/rocksdb url = https://github.com/facebook/rocksdb.git +[submodule "librocksdb-sys/lz4"] + path = librocksdb-sys/lz4 + url = https://github.com/lz4/lz4.git diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 08262d9..8b1d31d 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -49,10 +49,12 @@ fn build_rocksdb() { config.include("rocksdb/"); config.include("rocksdb/third-party/gtest-1.7.0/fused-src/"); config.include("snappy/"); + config.include("lz4/lib/"); config.include("."); config.define("NDEBUG", Some("1")); config.define("SNAPPY", Some("1")); + config.define("LZ4", Some("1")); let mut lib_sources = include_str!("rocksdb_lib_sources.txt") .split(" ") @@ -148,6 +150,28 @@ fn build_snappy() { config.compile("libsnappy.a"); } +fn build_lz4() { + let mut compiler = cc::Build::new(); + + compiler + .file("lz4/lib/lz4.c") + .file("lz4/lib/lz4frame.c") + .file("lz4/lib/lz4hc.c") + .file("lz4/lib/xxhash.c"); + + compiler.opt_level(3); + + match env::var("TARGET").unwrap().as_str() + { + "i686-pc-windows-gnu" => { + compiler.flag("-fno-tree-vectorize"); + }, + _ => {} + } + + compiler.compile("liblz4.a"); +} + fn try_to_find_and_link_lib(lib_name: &str) -> bool { if let Ok(lib_dir) = env::var(&format!("{}_LIB_DIR", lib_name)) { println!("cargo:rustc-link-search=native={}", lib_dir); @@ -165,9 +189,11 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=rocksdb/"); println!("cargo:rerun-if-changed=snappy/"); + println!("cargo:rerun-if-changed=lz4/"); fail_on_empty_directory("rocksdb"); fail_on_empty_directory("snappy"); + fail_on_empty_directory("lz4"); bindgen_rocksdb(); if !try_to_find_and_link_lib("ROCKSDB") { @@ -176,4 +202,7 @@ fn main() { if !try_to_find_and_link_lib("SNAPPY") { build_snappy(); } + if !try_to_find_and_link_lib("LZ4") { + build_lz4(); + } } diff --git a/librocksdb-sys/lz4 b/librocksdb-sys/lz4 new file mode 160000 index 0000000..c10863b --- /dev/null +++ b/librocksdb-sys/lz4 @@ -0,0 +1 @@ +Subproject commit c10863b98e1503af90616ae99725ecd120265dfb diff --git a/librocksdb-sys/snappy b/librocksdb-sys/snappy index efb39e8..2d99bd1 160000 --- a/librocksdb-sys/snappy +++ b/librocksdb-sys/snappy @@ -1 +1 @@ -Subproject commit efb39e81b8b66b757ec900db33657c47b4750740 +Subproject commit 2d99bd14d471664758e4dfdf81b44f413a7353fd diff --git a/librocksdb-sys/zstd b/librocksdb-sys/zstd new file mode 160000 index 0000000..f3a8bd5 --- /dev/null +++ b/librocksdb-sys/zstd @@ -0,0 +1 @@ +Subproject commit f3a8bd553a865c59f1bd6e1f68bf182cf75a8f00