From 1f2e18633c0c5156c1ef74eeb5507e8eeae35447 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Mon, 11 Nov 2024 23:44:05 +0100 Subject: [PATCH] Add `vendored` cargo feature --- Cargo.toml | 1 + zstd-safe/Cargo.toml | 1 + zstd-safe/zstd-sys/Cargo.toml | 1 + zstd-safe/zstd-sys/build.rs | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cd461049..2c7ac95d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ bindgen = ["zstd-safe/bindgen"] debug = ["zstd-safe/debug"] legacy = ["zstd-safe/legacy"] pkg-config = ["zstd-safe/pkg-config"] +vendored = ["zstd-safe/vendored"] wasm = [] zstdmt = ["zstd-safe/zstdmt"] experimental = ["zstd-safe/experimental"] diff --git a/zstd-safe/Cargo.toml b/zstd-safe/Cargo.toml index d325e775..3d7d50a9 100644 --- a/zstd-safe/Cargo.toml +++ b/zstd-safe/Cargo.toml @@ -27,6 +27,7 @@ debug = ["zstd-sys/debug"] experimental = ["zstd-sys/experimental"] legacy = ["zstd-sys/legacy"] pkg-config = ["zstd-sys/pkg-config"] +vendored = ["zstd-sys/vendored"] std = ["zstd-sys/std"] # Implements WriteBuf for std types like Cursor and Vec. zstdmt = ["zstd-sys/zstdmt"] thin = ["zstd-sys/thin"] diff --git a/zstd-safe/zstd-sys/Cargo.toml b/zstd-safe/zstd-sys/Cargo.toml index 651bb0d3..f7ec3a17 100644 --- a/zstd-safe/zstd-sys/Cargo.toml +++ b/zstd-safe/zstd-sys/Cargo.toml @@ -70,6 +70,7 @@ experimental = [] # Expose experimental ZSTD API legacy = [] # Enable legacy ZSTD support (for versions < zstd-0.8) non-cargo = [] # Silence cargo-specific build flags pkg-config = [] # Use pkg-config to build the zstd C library. +vendored = [] # Always use vendored source code of zstd C library. std = [] # Deprecated: we never use types from std. zstdmt = [] # Enable multi-thread support (with pthread) thin = [] # Optimize binary by size diff --git a/zstd-safe/zstd-sys/build.rs b/zstd-safe/zstd-sys/build.rs index e578f606..c135e63d 100644 --- a/zstd-safe/zstd-sys/build.rs +++ b/zstd-safe/zstd-sys/build.rs @@ -257,7 +257,8 @@ fn main() { } // println!("cargo:rustc-link-lib=zstd"); - let (defs, headerpaths) = if cfg!(feature = "pkg-config") + let (defs, headerpaths) = if (cfg!(feature = "pkg-config") + && !cfg!(feature = "vendored")) || env::var_os("ZSTD_SYS_USE_PKG_CONFIG").is_some() { pkg_config()