diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:55 +0000 |
commit | 2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch) | |
tree | 033cc839730fda84ff08db877037977be94e5e3a /vendor/libz-sys/build_zng.rs | |
parent | Initial commit. (diff) | |
download | cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.tar.xz cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.zip |
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/libz-sys/build_zng.rs')
-rw-r--r-- | vendor/libz-sys/build_zng.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/libz-sys/build_zng.rs b/vendor/libz-sys/build_zng.rs new file mode 100644 index 0000000..2557625 --- /dev/null +++ b/vendor/libz-sys/build_zng.rs @@ -0,0 +1,60 @@ +use std::env; + +pub fn build_zlib_ng(target: &str, compat: bool) { + let mut cmake = cmake::Config::new("src/zlib-ng"); + cmake + .define("BUILD_SHARED_LIBS", "OFF") + .define("ZLIB_COMPAT", if compat { "ON" } else { "OFF" }) + .define("ZLIB_ENABLE_TESTS", "OFF") + .define("WITH_GZFILEOP", "ON"); + if target.contains("s390x") { + // Enable hardware compression on s390x. + cmake + .define("WITH_DFLTCC_DEFLATE", "1") + .define("WITH_DFLTCC_INFLATE", "1") + .cflag("-DDFLTCC_LEVEL_MASK=0x7e"); + } + if target == "i686-pc-windows-msvc" { + cmake.define("CMAKE_GENERATOR_PLATFORM", "Win32"); + } + + let install_dir = cmake.build(); + + let includedir = install_dir.join("include"); + let libdir = install_dir.join("lib"); + let libdir64 = install_dir.join("lib64"); + println!( + "cargo:rustc-link-search=native={}", + libdir.to_str().unwrap() + ); + println!( + "cargo:rustc-link-search=native={}", + libdir64.to_str().unwrap() + ); + let mut debug_suffix = ""; + let libname = if target.contains("windows") && target.contains("msvc") { + if env::var("OPT_LEVEL").unwrap() == "0" { + debug_suffix = "d"; + } + "zlibstatic" + } else { + "z" + }; + println!( + "cargo:rustc-link-lib=static={}{}{}", + libname, + if compat { "" } else { "-ng" }, + debug_suffix, + ); + println!("cargo:root={}", install_dir.to_str().unwrap()); + println!("cargo:include={}", includedir.to_str().unwrap()); + if !compat { + println!("cargo:rustc-cfg=zng"); + } +} + +#[allow(dead_code)] +fn main() { + let target = env::var("TARGET").unwrap(); + build_zlib_ng(&target, false); +} |