diff --git a/.gitmodules b/.gitmodules index 0c44d00..2c818bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [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/Cargo.toml b/librocksdb-sys/Cargo.toml index 60d08a0..99dcf89 100644 --- a/librocksdb-sys/Cargo.toml +++ b/librocksdb-sys/Cargo.toml @@ -17,7 +17,7 @@ jemalloc = ["tikv-jemalloc-sys"] static = ["libz-sys?/static", "bzip2-sys?/static"] io-uring = ["pkg-config"] snappy = [] -lz4 = [] +lz4 = ["lz4-sys"] zstd = ["zstd-sys"] zlib = ["libz-sys"] bzip2 = ["bzip2-sys"] @@ -26,6 +26,7 @@ rtti = [] [dependencies] libc = "0.2" tikv-jemalloc-sys = { version = "0.5", features = ["unprefixed_malloc_on_supported_platforms"], optional = true } +lz4-sys = { version = "1.9", optional = true } zstd-sys = { version = "2.0", features = ["zdict_builder"], optional = true } libz-sys = { version = "1.1", default-features = false, optional = true } bzip2-sys = { version = "0.1", default-features = false, optional = true } diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index fac9abb..952d832 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -63,7 +63,9 @@ fn build_rocksdb() { if cfg!(feature = "lz4") { config.define("LZ4", Some("1")); - config.include("lz4/lib/"); + if let Some(path) = env::var_os("DEP_LZ4_INCLUDE") { + config.include(path); + } } if cfg!(feature = "zstd") { @@ -285,26 +287,6 @@ 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); - - let target = env::var("TARGET").unwrap(); - - if &target == "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(v) = env::var(&format!("{}_COMPILE", lib_name)) { if v.to_lowercase() == "true" || v == "1" { @@ -378,11 +360,6 @@ fn main() { fail_on_empty_directory("snappy"); build_snappy(); } - if cfg!(feature = "lz4") && !try_to_find_and_link_lib("LZ4") { - println!("cargo:rerun-if-changed=lz4/"); - fail_on_empty_directory("lz4"); - build_lz4(); - } // Allow dependent crates to locate the sources and output directory of // this crate. Notably, this allows a dependent crate to locate the RocksDB diff --git a/librocksdb-sys/lz4 b/librocksdb-sys/lz4 deleted file mode 160000 index d443718..0000000 --- a/librocksdb-sys/lz4 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d44371841a2f1728a3f36839fd4b7e872d0927d3 diff --git a/librocksdb-sys/src/lib.rs b/librocksdb-sys/src/lib.rs index 3325412..c723615 100644 --- a/librocksdb-sys/src/lib.rs +++ b/librocksdb-sys/src/lib.rs @@ -22,6 +22,8 @@ extern crate bzip2_sys; #[cfg(feature = "zlib")] extern crate libz_sys; +#[cfg(feature = "lz4")] +extern crate lz4_sys; #[cfg(feature = "zstd")] extern crate zstd_sys;