Use lz4-sys crate rather then submodule (#679)

master
Niklas Fiekas 2 years ago committed by GitHub
parent f4b1bd3570
commit 76d85e9c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .gitmodules
  2. 3
      librocksdb-sys/Cargo.toml
  3. 29
      librocksdb-sys/build.rs
  4. 1
      librocksdb-sys/lz4
  5. 2
      librocksdb-sys/src/lib.rs

3
.gitmodules vendored

@ -4,6 +4,3 @@
[submodule "rocksdb_sys/rocksdb"] [submodule "rocksdb_sys/rocksdb"]
path = librocksdb-sys/rocksdb path = librocksdb-sys/rocksdb
url = https://github.com/facebook/rocksdb.git url = https://github.com/facebook/rocksdb.git
[submodule "librocksdb-sys/lz4"]
path = librocksdb-sys/lz4
url = https://github.com/lz4/lz4.git

@ -17,7 +17,7 @@ jemalloc = ["tikv-jemalloc-sys"]
static = ["libz-sys?/static", "bzip2-sys?/static"] static = ["libz-sys?/static", "bzip2-sys?/static"]
io-uring = ["pkg-config"] io-uring = ["pkg-config"]
snappy = [] snappy = []
lz4 = [] lz4 = ["lz4-sys"]
zstd = ["zstd-sys"] zstd = ["zstd-sys"]
zlib = ["libz-sys"] zlib = ["libz-sys"]
bzip2 = ["bzip2-sys"] bzip2 = ["bzip2-sys"]
@ -26,6 +26,7 @@ rtti = []
[dependencies] [dependencies]
libc = "0.2" libc = "0.2"
tikv-jemalloc-sys = { version = "0.5", features = ["unprefixed_malloc_on_supported_platforms"], optional = true } 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 } zstd-sys = { version = "2.0", features = ["zdict_builder"], optional = true }
libz-sys = { version = "1.1", default-features = false, optional = true } libz-sys = { version = "1.1", default-features = false, optional = true }
bzip2-sys = { version = "0.1", default-features = false, optional = true } bzip2-sys = { version = "0.1", default-features = false, optional = true }

@ -63,7 +63,9 @@ fn build_rocksdb() {
if cfg!(feature = "lz4") { if cfg!(feature = "lz4") {
config.define("LZ4", Some("1")); 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") { if cfg!(feature = "zstd") {
@ -285,26 +287,6 @@ fn build_snappy() {
config.compile("libsnappy.a"); 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 { fn try_to_find_and_link_lib(lib_name: &str) -> bool {
if let Ok(v) = env::var(&format!("{}_COMPILE", lib_name)) { if let Ok(v) = env::var(&format!("{}_COMPILE", lib_name)) {
if v.to_lowercase() == "true" || v == "1" { if v.to_lowercase() == "true" || v == "1" {
@ -378,11 +360,6 @@ fn main() {
fail_on_empty_directory("snappy"); fail_on_empty_directory("snappy");
build_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 // Allow dependent crates to locate the sources and output directory of
// this crate. Notably, this allows a dependent crate to locate the RocksDB // this crate. Notably, this allows a dependent crate to locate the RocksDB

@ -1 +0,0 @@
Subproject commit d44371841a2f1728a3f36839fd4b7e872d0927d3

@ -22,6 +22,8 @@
extern crate bzip2_sys; extern crate bzip2_sys;
#[cfg(feature = "zlib")] #[cfg(feature = "zlib")]
extern crate libz_sys; extern crate libz_sys;
#[cfg(feature = "lz4")]
extern crate lz4_sys;
#[cfg(feature = "zstd")] #[cfg(feature = "zstd")]
extern crate zstd_sys; extern crate zstd_sys;

Loading…
Cancel
Save