diff --git a/zstd-safe/zstd-sys/Cargo.toml b/zstd-safe/zstd-sys/Cargo.toml index a9afae2c..a208949d 100644 --- a/zstd-safe/zstd-sys/Cargo.toml +++ b/zstd-safe/zstd-sys/Cargo.toml @@ -61,7 +61,7 @@ features = ["parallel"] libc = "0.2.45" [features] -default = ["legacy", "dict_builder"] +default = ["legacy", "zdict"] debug = [] # Enable zstd debug logs experimental = [] # Expose experimental ZSTD API @@ -71,4 +71,4 @@ std = [] # Use std types instead of libc in bindgen zstdmt = [] # Enable multi-thread support (with pthread) thin = [] # Optimize binary by size no_asm = [] # Disable ASM files (only on amd64 for decompression) -dict_builder = [] +zdict = [] diff --git a/zstd-safe/zstd-sys/build.rs b/zstd-safe/zstd-sys/build.rs index 373f989d..8819bdf7 100644 --- a/zstd-safe/zstd-sys/build.rs +++ b/zstd-safe/zstd-sys/build.rs @@ -5,8 +5,10 @@ use std::{env, fs}; #[cfg(feature = "bindgen")] fn generate_bindings(defs: Vec<&str>, headerpaths: Vec) { let bindings = bindgen::Builder::default() - .header("zstd.h") - .header("zdict.h") + .header("zstd.h"); + #[cfg(feature = "zdict")] + let bindings = bindings.header("zdict.h"); + bindings .blocklist_type("max_align_t") .size_t_is_usize(true) .use_core() @@ -19,9 +21,10 @@ fn generate_bindings(defs: Vec<&str>, headerpaths: Vec) { .clang_args(defs.into_iter().map(|def| format!("-D{}", def))); #[cfg(feature = "experimental")] - let bindings = bindings - .clang_arg("-DZSTD_STATIC_LINKING_ONLY") - .clang_arg("-DZDICT_STATIC_LINKING_ONLY"); + let bindings = bindings.clang_arg("-DZSTD_STATIC_LINKING_ONLY"); + #[cfg(feature = "experimental")] + #[cfg(feature = "zdict")] + let bindings = bindings.clang_arg("-DZDICT_STATIC_LINKING_ONLY"); #[cfg(not(feature = "std"))] let bindings = bindings.ctypes_prefix("libc"); @@ -85,7 +88,7 @@ fn compile_zstd() { "zstd/lib/common", "zstd/lib/compress", "zstd/lib/decompress", - #[cfg(feature = "dict_builder")] + #[cfg(feature = "zdict")] "zstd/lib/dictBuilder", #[cfg(feature = "legacy")] "zstd/lib/legacy", @@ -146,6 +149,7 @@ fn compile_zstd() { config.flag("-fvisibility=hidden"); config.define("XXH_PRIVATE_API", Some("")); config.define("ZSTDLIB_VISIBILITY", Some("")); + #[cfg(feature = "zdict")] config.define("ZDICTLIB_VISIBILITY", Some("")); config.define("ZSTDERRORLIB_VISIBILITY", Some("")); @@ -179,6 +183,7 @@ fn compile_zstd() { fs::copy(src.join("zstd.h"), include.join("zstd.h")).unwrap(); fs::copy(src.join("zstd_errors.h"), include.join("zstd_errors.h")) .unwrap(); + #[cfg(feature = "zdict")] fs::copy(src.join("zdict.h"), include.join("zdict.h")).unwrap(); println!("cargo:root={}", dst.display()); } diff --git a/zstd-safe/zstd-sys/src/lib.rs b/zstd-safe/zstd-sys/src/lib.rs index 71cf7a87..bcc1a9ee 100644 --- a/zstd-safe/zstd-sys/src/lib.rs +++ b/zstd-safe/zstd-sys/src/lib.rs @@ -29,6 +29,7 @@ include!("bindings_zstd.rs"); #[cfg(all( not(feature = "std"), not(feature = "experimental"), + feature = "zdict", not(feature = "bindgen") ))] include!("bindings_zdict.rs"); @@ -43,6 +44,7 @@ include!("bindings_zstd_experimental.rs"); #[cfg(all( not(feature = "std"), feature = "experimental", + feature = "zdict", not(feature = "bindgen") ))] include!("bindings_zdict_experimental.rs"); @@ -59,6 +61,7 @@ include!("bindings_zstd_std.rs"); #[cfg(all( feature = "std", not(feature = "experimental"), + feature = "zdict", not(feature = "bindgen") ))] include!("bindings_zdict_std.rs"); @@ -73,6 +76,7 @@ include!("bindings_zstd_std_experimental.rs"); #[cfg(all( feature = "std", feature = "experimental", + feature = "zdict", not(feature = "bindgen") ))] include!("bindings_zdict_std_experimental.rs");