From c0b2e5f24eccb9c1d337699ee4fadf047a4a6634 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 1 Feb 2024 10:24:46 +0100 Subject: [PATCH] Rename feature Also make it so that --all-features works --- Cargo.toml | 9 +++++++-- README.md | 3 ++- build.rs | 24 +++++++++++++++++++----- ci/test.bash | 4 ++-- systest/Cargo.toml | 4 +++- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a1ca334a..40206f08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,8 +60,13 @@ default = ["libc", "stock-zlib"] # This allows higher-level crates depending on your library to opt into zlib-ng # if desired. zlib-ng = ["libc", "cmake"] -# Builds zlib-ng from source using cc instead of cmake -zlib-ng-no-cmake = ["libc"] +# Builds zlib-ng from source using cc instead of cmake with all target features +# enabled, meaning compilation may not work depending on your target and host +# toolchain (eg very old compilers won't have some flags) +# +# This feature is not maintained by the repo maintainers and can break at any time +# or be completely removed in the future +zlib-ng-no-cmake-experimental-community-maintained- = ["libc"] stock-zlib = [] # Deprecated: the assembly routines are outdated, and either reduce performance # or cause segfaults. diff --git a/README.md b/README.md index c6f53f40..87cd9d98 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,8 @@ libz-sys = { version = "1.1", default-features = false, features = ["libc"] } This allows higher-level crates depending on your library to opt into zlib-ng if desired. -Building zlib-ng requires `cmake` unless the `zlib-ng-no-cmake` feature is enabled, +Building zlib-ng requires `cmake` unless the +`zlib-ng-no-cmake-experimental-community-maintained` feature is enabled, in which case `cc` is used instead. Note that this option enables _all_ compiler features that are supported for the given target, which may not compile on older compilers or targets without certain headers. diff --git a/build.rs b/build.rs index 4b7e6501..acfdbb0d 100644 --- a/build.rs +++ b/build.rs @@ -13,8 +13,10 @@ fn main() { let host_and_target_contain = |s| host.contains(s) && target.contains(s); - let want_ng = cfg!(any(feature = "zlib-ng", feature = "zlib-ng-no-cmake")) - && !cfg!(feature = "stock-zlib"); + let want_ng = cfg!(any( + feature = "zlib-ng", + feature = "zlib-ng-no-cmake-experimental-community-maintained" + )) && !cfg!(feature = "stock-zlib"); if want_ng && target != "wasm32-unknown-unknown" { return build_zlib_ng(&target, true); @@ -165,17 +167,29 @@ fn build_zlib(cfg: &mut cc::Build, target: &str) { println!("cargo:include={}/include", dst.to_str().unwrap()); } -#[cfg(any(feature = "zlib-ng", feature = "zlib-ng-no-cmake"))] +#[cfg(any( + feature = "zlib-ng", + feature = "zlib-ng-no-cmake-experimental-community-maintained" +))] mod zng { #[cfg_attr(feature = "zlib-ng", path = "cmake.rs")] - #[cfg_attr(feature = "zlib-ng-no-cmake", path = "cc.rs")] + #[cfg_attr( + all( + feature = "zlib-ng-no-cmake-experimental-community-maintained", + not(feature = "zlib-ng") + ), + path = "cc.rs" + )] mod build_zng; pub(super) use build_zng::build_zlib_ng; } fn build_zlib_ng(_target: &str, _compat: bool) { - #[cfg(any(feature = "zlib-ng", feature = "zlib-ng-no-cmake"))] + #[cfg(any( + feature = "zlib-ng", + feature = "zlib-ng-no-cmake-experimental-community-maintained" + ))] zng::build_zlib_ng(_target, _compat); } diff --git a/ci/test.bash b/ci/test.bash index a780b229..1c57a074 100755 --- a/ci/test.bash +++ b/ci/test.bash @@ -42,8 +42,8 @@ echo '::endgroup::' skip_triples=("x86_64-unknown-linux-gnu" "i686-unknown-linux-gnu" "aarch64-unknown-linux-gnu" "arm-unknown-linux-gnueabihf") if [[ -z $CI ]] || ! [[ ${skip_triples[@]} =~ "${TARGET_TRIPLE}" ]]; then echo '::group::=== zlib-ng-no-cmake build ===' - $CROSS test --target "$TARGET_TRIPLE" --no-default-features --features zlib-ng-no-cmake - $CROSS run --target "$TARGET_TRIPLE" --manifest-path systest/Cargo.toml --no-default-features --features zlib-ng-no-cmake + $CROSS test --target "$TARGET_TRIPLE" --no-default-features --features zlib-ng-no-cmake-experimental-community-maintained + $CROSS run --target "$TARGET_TRIPLE" --manifest-path systest/Cargo.toml --no-default-features --features zlib-ng-no-cmake-experimental-community-maintained echo '::endgroup::' fi diff --git a/systest/Cargo.toml b/systest/Cargo.toml index 7123f97b..de1d7704 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -14,4 +14,6 @@ ctest2 = "0.4.4" [features] libz-static = ["libz-sys/static"] zlib-ng = ["libz-sys/zlib-ng"] -zlib-ng-no-cmake = ["libz-sys/zlib-ng-no-cmake"] +zlib-ng-no-cmake-experimental-community-maintained = [ + "libz-sys/zlib-ng-no-cmake-experimental-community-maintained", +]