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 | |
parent | Initial commit. (diff) | |
download | cargo-upstream.tar.xz cargo-upstream.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')
-rw-r--r-- | vendor/libz-sys/.cargo-checksum.json | 1 | ||||
-rw-r--r-- | vendor/libz-sys/Cargo.toml | 59 | ||||
-rw-r--r-- | vendor/libz-sys/LICENSE-APACHE | 201 | ||||
-rw-r--r-- | vendor/libz-sys/LICENSE-MIT | 26 | ||||
-rw-r--r-- | vendor/libz-sys/README-zng.md | 57 | ||||
-rw-r--r-- | vendor/libz-sys/README.md | 74 | ||||
-rw-r--r-- | vendor/libz-sys/build.rs | 187 | ||||
-rw-r--r-- | vendor/libz-sys/build_zng.rs | 60 | ||||
-rw-r--r-- | vendor/libz-sys/debian/patches/disable-zlib-ng.patch | 21 | ||||
-rw-r--r-- | vendor/libz-sys/debian/patches/remove-static.patch | 87 | ||||
-rw-r--r-- | vendor/libz-sys/debian/patches/series | 2 | ||||
-rw-r--r-- | vendor/libz-sys/src/lib.rs | 431 | ||||
-rw-r--r-- | vendor/libz-sys/src/smoke.c | 5 |
13 files changed, 1211 insertions, 0 deletions
diff --git a/vendor/libz-sys/.cargo-checksum.json b/vendor/libz-sys/.cargo-checksum.json new file mode 100644 index 0000000..0cfc099 --- /dev/null +++ b/vendor/libz-sys/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{},"package":"d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b"}
\ No newline at end of file diff --git a/vendor/libz-sys/Cargo.toml b/vendor/libz-sys/Cargo.toml new file mode 100644 index 0000000..ed22f1c --- /dev/null +++ b/vendor/libz-sys/Cargo.toml @@ -0,0 +1,59 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "libz-sys" +version = "1.1.12" +authors = [ + "Alex Crichton <alex@alexcrichton.com>", + "Josh Triplett <josh@joshtriplett.org>", + "Sebastian Thiel <sebastian.thiel@icloud.com>", +] +links = "z" +exclude = [ + "/.github", + "/.gitmodules", + "/Cargo-zng.toml", + "/cargo-zng", + "/ci", + "/systest", +] +description = "Low-level bindings to the system libz library (also known as zlib)." +readme = "README.md" +keywords = [ + "zlib", + "zlib-ng", +] +categories = [ + "compression", + "external-ffi-bindings", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/libz-sys" + +[dependencies.libc] +version = "0.2.43" +optional = true + +[build-dependencies.pkg-config] +version = "0.3.9" + +[build-dependencies.vcpkg] +version = "0.2" + +[features] +asm = [] +default = [ + "libc", + "stock-zlib", +] +stock-zlib = [] diff --git a/vendor/libz-sys/LICENSE-APACHE b/vendor/libz-sys/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/vendor/libz-sys/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/libz-sys/LICENSE-MIT b/vendor/libz-sys/LICENSE-MIT new file mode 100644 index 0000000..960ff42 --- /dev/null +++ b/vendor/libz-sys/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright (c) 2014 Alex Crichton +Copyright (c) 2020 Josh Triplett + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/vendor/libz-sys/README-zng.md b/vendor/libz-sys/README-zng.md new file mode 100644 index 0000000..4ac40e0 --- /dev/null +++ b/vendor/libz-sys/README-zng.md @@ -0,0 +1,57 @@ +# libz-ng-sys + +A library for linking zlib-ng (`libz-ng`) to Rust programs natively, rather +than in zlib-compat mode. + +zlib-ng is a high-performance implementation of zlib. zlib-ng supports building +in two modes: zlib-compat mode, in whih it provides the same API as zlib and +generally works as a drop-in replacement, and native mode, in which it provides +its own API. The native API is almost identical to the zlib-compat API, except +that some types use more correct sizes (rather than the sizes required for zlib +compatibility), and the functions all have a `zng_` prefix. The latter allows +zlib and zlib-ng to coexist in the same program. + +This crate provides bindings to the native zlib-ng API. However, for simplicity +of porting, this crate exports the same API as libz-sys (without the `zng_` +prefixes), making it easier to write Rust software compatible with both +libz-sys and libz-ng-sys. + +# High-level API + +This crate provides bindings to the raw low-level C API. For a higher-level +safe API to work with DEFLATE, zlib, or gzip streams, see +[`flate2`](https://docs.rs/flate2). `flate2` supports many different +implementations. + +# Development + +This crate is built from [the same sources as +`libz-sys`](https://github.com/rust-lang/libz-sys). From within those sources, +`Cargo.toml` is the manifest for `libz-sys`, and `Cargo-zng.toml` is the +manifest for `libz-ng-sys`. The script `./cargo-zng` invokes Cargo on a +temporary copy of the sources with `Cargo-zng.toml` replacing `Cargo.toml`; for +instance, use `./cargo-zng publish` to publish `libz-ng-sys`. + +# Minimum Supported Rust Version (MSRV) Policy + +This crate uses the same MSRV policy as the +[`flate2`](https://crates.io/crates/flate2) crate: This crate supports the +current and previous stable versions of Rust. Older versions of Rust may work, +but we don't guarantee these will continue to work. + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in this crate by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. diff --git a/vendor/libz-sys/README.md b/vendor/libz-sys/README.md new file mode 100644 index 0000000..26088b1 --- /dev/null +++ b/vendor/libz-sys/README.md @@ -0,0 +1,74 @@ +# libz-sys + +A common library for linking `libz` to rust programs (also known as zlib). + +[Documentation](https://docs.rs/libz-sys) + +This also serves as the source for the `libz-ng-sys` crate, which builds +zlib-ng natively (not in zlib-compat mode). See +[`README-zng.md`](README-zng.md) for details. + +# High-level API + +This crate provides bindings to the raw low-level C API. For a higher-level +safe API to work with DEFLATE, zlib, or gzip streams, see +[`flate2`](https://docs.rs/flate2). `flate2` also supports alternative +implementations, including slower but pure Rust implementations. + +# zlib-ng + +This crate supports building either the high-performance zlib-ng (in +zlib-compat mode), or the widely available stock zlib. + +By default, `libz-sys` uses stock zlib, primarily because doing so allows the +use of a shared system zlib library if available. + +Any application or library designed for zlib should work with zlib-ng in +zlib-compat mode, as long as it doesn't make assumptions about the exact size +or output of the deflated data (e.g. "compressing this data produces exactly +this many bytes"), and as long as you don't also dynamically pull in a copy of +stock zlib (which will produce conflicting symbols). Nonetheless, for maximum +compatibility, every library crate in a build must opt into allowing zlib-ng; +if any library crate in your dependency graph wants stock zlib, `libz-sys` will +use stock zlib. + +Library crates depending on `libz-sys` should use: +``` +libz-sys = { version = "1.1.0", default-features = false, features = ["libc"] } +``` +(Omit the `libc` feature if you don't require the corresponding functions.) + +This allows higher-level crates depending on your library to opt into zlib-ng +if desired. + +Building zlib-ng requires `cmake`. + +Crates that don't require compatibility with the zlib C API, and use zlib +exclusively from Rust or support the zlib-ng native C API (prefixed with +`zng_`) can use [`libz-ng-sys`](https://crates.io/crates/libz-ng-sys) instead, +which allows zlib and zlib-ng to coexist in the same program. See +[README-zng.md](README-zng.md) for details. + +# Minimum Supported Rust Version (MSRV) Policy + +This crate uses the same MSRV policy as the +[`flate2`](https://crates.io/crates/flate2) crate: This crate supports the +current and previous stable versions of Rust. Older versions of Rust may work, +but we don't guarantee these will continue to work. + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in `libz-sys` by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/vendor/libz-sys/build.rs b/vendor/libz-sys/build.rs new file mode 100644 index 0000000..0f8732a --- /dev/null +++ b/vendor/libz-sys/build.rs @@ -0,0 +1,187 @@ +use std::env; +use std::fs; +use std::path::PathBuf; + +fn main() { + println!("cargo:rerun-if-env-changed=LIBZ_SYS_STATIC"); + println!("cargo:rerun-if-changed=build.rs"); + let host = env::var("HOST").unwrap(); + let target = env::var("TARGET").unwrap(); + + let host_and_target_contain = |s| host.contains(s) && target.contains(s); + + let want_ng = false; /*cfg!(feature = "zlib-ng") && !cfg!(feature = "stock-zlib"); + + if want_ng && target != "wasm32-unknown-unknown" { + return build_zlib_ng(&target, true); + }*/ + + // Don't run pkg-config if we're linking statically (we'll build below) and + // also don't run pkg-config on FreeBSD/DragonFly. That'll end up printing + // `-L /usr/lib` which wreaks havoc with linking to an OpenSSL in /usr/local/lib + // (Ports, etc.) + let want_static = false; + cfg!(feature = "static") || env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1"; + if !want_static && + !target.contains("msvc") && // pkg-config just never works here + !(host_and_target_contain("freebsd") || + host_and_target_contain("dragonfly")) + { + // Don't print system lib dirs to cargo since this interferes with other + // packages adding non-system search paths to link against libraries + // that are also found in a system-wide lib dir. + let zlib = pkg_config::Config::new() + .cargo_metadata(true) + .print_system_libs(false) + .probe("zlib"); + match zlib { + Ok(_) => return, + Err(e) => { + println!("cargo-warning={}", e.to_string()) + } + } + } + + /*if target.contains("windows") { + if try_vcpkg() { + return; + } + }*/ + + // All android compilers should come with libz by default, so let's just use + // the one already there. Likewise, Haiku always ships with libz, so we can + // link to it even when cross-compiling. + if target.contains("android") || target.contains("haiku") { + println!("cargo:rustc-link-lib=z"); + return; + } + + /*let mut cfg = cc::Build::new(); + + // Situations where we build unconditionally. + // + // MSVC basically never has it preinstalled, MinGW picks up a bunch of weird + // paths we don't like, `want_static` may force us, and cross compiling almost + // never has a prebuilt version. + // + // Apple platforms have libz.1.dylib, and it's usually available even when + // cross compiling (via fat binary or in the target's Xcode SDK) + let cross_compiling = target != host; + let apple_to_apple = host.contains("-apple-") && target.contains("-apple-"); + if target.contains("msvc") + || target.contains("pc-windows-gnu") + || want_static + || (cross_compiling && !apple_to_apple) + { + return build_zlib(&mut cfg, &target); + } + + // If we've gotten this far we're probably a pretty standard platform. + // Almost all platforms here ship libz by default, but some don't have + // pkg-config files that we would find above. + // + // In any case test if zlib is actually installed and if so we link to it, + // otherwise continue below to build things. + if zlib_installed(&mut cfg) { + println!("cargo:rustc-link-lib=z"); + return; + } + + build_zlib(&mut cfg, &target)*/ +} + +/*fn build_zlib(cfg: &mut cc::Build, target: &str) { + let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let lib = dst.join("lib"); + + cfg.warnings(false).out_dir(&lib).include("src/zlib"); + + cfg.file("src/zlib/adler32.c") + .file("src/zlib/compress.c") + .file("src/zlib/crc32.c") + .file("src/zlib/deflate.c") + .file("src/zlib/infback.c") + .file("src/zlib/inffast.c") + .file("src/zlib/inflate.c") + .file("src/zlib/inftrees.c") + .file("src/zlib/trees.c") + .file("src/zlib/uncompr.c") + .file("src/zlib/zutil.c"); + + if !cfg!(feature = "libc") || target.starts_with("wasm32") { + cfg.define("Z_SOLO", None); + } else { + cfg.file("src/zlib/gzclose.c") + .file("src/zlib/gzlib.c") + .file("src/zlib/gzread.c") + .file("src/zlib/gzwrite.c"); + } + + if !target.contains("windows") { + cfg.define("STDC", None); + cfg.define("_LARGEFILE64_SOURCE", None); + cfg.define("_POSIX_SOURCE", None); + cfg.flag("-fvisibility=hidden"); + } + if target.contains("apple") { + cfg.define("_C99_SOURCE", None); + } + if target.contains("solaris") { + cfg.define("_XOPEN_SOURCE", "700"); + } + + cfg.compile("z"); + + fs::create_dir_all(dst.join("include")).unwrap(); + fs::copy("src/zlib/zlib.h", dst.join("include/zlib.h")).unwrap(); + fs::copy("src/zlib/zconf.h", dst.join("include/zconf.h")).unwrap(); + + fs::create_dir_all(lib.join("pkgconfig")).unwrap(); + fs::write( + lib.join("pkgconfig/zlib.pc"), + fs::read_to_string("src/zlib/zlib.pc.in") + .unwrap() + .replace("@prefix@", dst.to_str().unwrap()), + ) + .unwrap(); + + println!("cargo:root={}", dst.to_str().unwrap()); + println!("cargo:rustc-link-search=native={}", lib.to_str().unwrap()); + println!("cargo:include={}/include", dst.to_str().unwrap()); +} + +#[cfg(not(feature = "zlib-ng"))] +fn build_zlib_ng(_target: &str, _compat: bool) {} + +#[cfg(feature = "zlib-ng")] +mod build_zng; +#[cfg(feature = "zlib-ng")] +use build_zng::build_zlib_ng; + +fn try_vcpkg() -> bool { + // see if there is a vcpkg tree with zlib installed + match vcpkg::Config::new() + .emit_includes(true) + .find_package("zlib") + { + Ok(_) => true, + Err(e) => { + println!("note, vcpkg did not find zlib: {}", e); + false + } + } +} + +fn zlib_installed(cfg: &mut cc::Build) -> bool { + let mut cmd = cfg.get_compiler().to_command(); + cmd.arg("src/smoke.c").arg("-o").arg("/dev/null").arg("-lz"); + + println!("running {:?}", cmd); + if let Ok(status) = cmd.status() { + if status.success() { + return true; + } + } + + false +}*/ 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); +} diff --git a/vendor/libz-sys/debian/patches/disable-zlib-ng.patch b/vendor/libz-sys/debian/patches/disable-zlib-ng.patch new file mode 100644 index 0000000..e14ea4f --- /dev/null +++ b/vendor/libz-sys/debian/patches/disable-zlib-ng.patch @@ -0,0 +1,21 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -65,7 +65,3 @@ + ] + static = [] + stock-zlib = [] +-zlib-ng = [ +- "libc", +- "cmake", +-] +--- a/build.rs ++++ b/build.rs +@@ -10,7 +10,7 @@ + + let host_and_target_contain = |s| host.contains(s) && target.contains(s); + +- let want_ng = cfg!(feature = "zlib-ng") && !cfg!(feature = "stock-zlib"); ++ let want_ng = false; cfg!(feature = "zlib-ng") && !cfg!(feature = "stock-zlib"); + + if want_ng && target != "wasm32-unknown-unknown" { + return build_zlib_ng(&target, true); diff --git a/vendor/libz-sys/debian/patches/remove-static.patch b/vendor/libz-sys/debian/patches/remove-static.patch new file mode 100644 index 0000000..017eeb4 --- /dev/null +++ b/vendor/libz-sys/debian/patches/remove-static.patch @@ -0,0 +1,87 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -44,13 +44,6 @@ + version = "0.2.43" + optional = true + +-[build-dependencies.cc] +-version = "1.0.18" +- +-[build-dependencies.cmake] +-version = "0.1.44" +-optional = true +- + [build-dependencies.pkg-config] + version = "0.3.9" + +@@ -63,5 +56,4 @@ + "libc", + "stock-zlib", + ] +-static = [] + stock-zlib = [] +--- a/build.rs ++++ b/build.rs +@@ -10,17 +10,17 @@ + + let host_and_target_contain = |s| host.contains(s) && target.contains(s); + +- let want_ng = false; cfg!(feature = "zlib-ng") && !cfg!(feature = "stock-zlib"); ++ let want_ng = false; /*cfg!(feature = "zlib-ng") && !cfg!(feature = "stock-zlib"); + + if want_ng && target != "wasm32-unknown-unknown" { + return build_zlib_ng(&target, true); +- } ++ }*/ + + // Don't run pkg-config if we're linking statically (we'll build below) and + // also don't run pkg-config on FreeBSD/DragonFly. That'll end up printing + // `-L /usr/lib` which wreaks havoc with linking to an OpenSSL in /usr/local/lib + // (Ports, etc.) +- let want_static = ++ let want_static = false; + cfg!(feature = "static") || env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1"; + if !want_static && + !target.contains("msvc") && // pkg-config just never works here +@@ -42,11 +42,11 @@ + } + } + +- if target.contains("windows") { ++ /*if target.contains("windows") { + if try_vcpkg() { + return; + } +- } ++ }*/ + + // All android compilers should come with libz by default, so let's just use + // the one already there. Likewise, Haiku always ships with libz, so we can +@@ -56,7 +56,7 @@ + return; + } + +- let mut cfg = cc::Build::new(); ++ /*let mut cfg = cc::Build::new(); + + // Situations where we build unconditionally. + // +@@ -87,10 +87,10 @@ + return; + } + +- build_zlib(&mut cfg, &target) ++ build_zlib(&mut cfg, &target)*/ + } + +-fn build_zlib(cfg: &mut cc::Build, target: &str) { ++/*fn build_zlib(cfg: &mut cc::Build, target: &str) { + let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let lib = dst.join("lib"); + +@@ -184,4 +184,4 @@ + } + + false +-} ++}*/ diff --git a/vendor/libz-sys/debian/patches/series b/vendor/libz-sys/debian/patches/series new file mode 100644 index 0000000..29c75f0 --- /dev/null +++ b/vendor/libz-sys/debian/patches/series @@ -0,0 +1,2 @@ +disable-zlib-ng.patch +remove-static.patch diff --git a/vendor/libz-sys/src/lib.rs b/vendor/libz-sys/src/lib.rs new file mode 100644 index 0000000..ae00583 --- /dev/null +++ b/vendor/libz-sys/src/lib.rs @@ -0,0 +1,431 @@ +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +use std::os::raw::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void}; + +// Macro for variances between zlib-ng in native mode and either zlib or zlib-ng in zlib compat +// mode. Note in particular that zlib-ng in compat mode does *not* use the zng case. +#[cfg(not(zng))] +macro_rules! if_zng { + ($_zng:tt, $not_zng:tt) => { + $not_zng + }; +} + +#[cfg(zng)] +macro_rules! if_zng { + ($zng:tt, $_not_zng:tt) => { + $zng + }; +} + +// zlib uses unsigned long for various sizes; zlib-ng uses size_t. +type z_size = if_zng!(usize, c_ulong); + +// zlib stores Adler-32 and CRC-32 checksums in unsigned long; zlib-ng uses uint32_t. +type z_checksum = if_zng!(u32, c_ulong); + +pub type alloc_func = unsafe extern "C" fn(voidpf, uInt, uInt) -> voidpf; +pub type Bytef = u8; +pub type free_func = unsafe extern "C" fn(voidpf, voidpf); +#[cfg(any(zng, feature = "libc"))] +pub type gzFile = *mut gzFile_s; +pub type in_func = unsafe extern "C" fn(*mut c_void, *mut *const c_uchar) -> c_uint; +pub type out_func = unsafe extern "C" fn(*mut c_void, *mut c_uchar, c_uint) -> c_int; +pub type uInt = c_uint; +pub type uLong = c_ulong; +pub type uLongf = c_ulong; +pub type voidp = *mut c_void; +pub type voidpc = *const c_void; +pub type voidpf = *mut c_void; + +#[cfg(any(zng, feature = "libc"))] +pub enum gzFile_s {} +pub enum internal_state {} + +#[cfg(all( + not(zng), + feature = "libc", + not(all(target_family = "wasm", target_os = "unknown")) +))] +pub type z_off_t = libc::off_t; + +#[cfg(all( + not(zng), + feature = "libc", + all(target_family = "wasm", target_os = "unknown") +))] +pub type z_off_t = c_long; + +#[cfg(all(zng, windows, not(target_env = "gnu")))] +pub type z_off_t = i64; + +#[cfg(all(zng, not(all(windows, not(target_env = "gnu")))))] +pub type z_off_t = libc::off_t; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct gz_header { + pub text: c_int, + pub time: uLong, + pub xflags: c_int, + pub os: c_int, + pub extra: *mut Bytef, + pub extra_len: uInt, + pub extra_max: uInt, + pub name: *mut Bytef, + pub name_max: uInt, + pub comment: *mut Bytef, + pub comm_max: uInt, + pub hcrc: c_int, + pub done: c_int, +} +pub type gz_headerp = *mut gz_header; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct z_stream { + pub next_in: *mut Bytef, + pub avail_in: uInt, + pub total_in: z_size, + pub next_out: *mut Bytef, + pub avail_out: uInt, + pub total_out: z_size, + pub msg: *mut c_char, + pub state: *mut internal_state, + pub zalloc: alloc_func, + pub zfree: free_func, + pub opaque: voidpf, + pub data_type: c_int, + pub adler: z_checksum, + pub reserved: uLong, +} +pub type z_streamp = *mut z_stream; + +// Ideally, this should instead use a macro that parses the whole block of externs, and generates +// the appropriate link_name attributes, without duplicating the function names. However, ctest2 +// can't parse that. +#[cfg(not(zng))] +macro_rules! zng_prefix { + ($name:expr) => { + stringify!($name) + }; +} + +#[cfg(zng)] +macro_rules! zng_prefix { + ($name:expr) => { + concat!("zng_", stringify!($name)) + }; +} + +extern "C" { + #[link_name = zng_prefix!(adler32)] + pub fn adler32(adler: z_checksum, buf: *const Bytef, len: uInt) -> z_checksum; + #[link_name = zng_prefix!(crc32)] + pub fn crc32(crc: z_checksum, buf: *const Bytef, len: uInt) -> z_checksum; + #[link_name = zng_prefix!(deflate)] + pub fn deflate(strm: z_streamp, flush: c_int) -> c_int; + #[link_name = zng_prefix!(deflateBound)] + pub fn deflateBound(strm: z_streamp, sourceLen: uLong) -> uLong; + #[link_name = zng_prefix!(deflateCopy)] + pub fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_int; + #[link_name = zng_prefix!(deflateEnd)] + pub fn deflateEnd(strm: z_streamp) -> c_int; + #[link_name = zng_prefix!(deflateParams)] + pub fn deflateParams(strm: z_streamp, level: c_int, strategy: c_int) -> c_int; + #[link_name = zng_prefix!(deflatePrime)] + pub fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; + #[link_name = zng_prefix!(deflateReset)] + pub fn deflateReset(strm: z_streamp) -> c_int; + #[link_name = zng_prefix!(deflateSetDictionary)] + pub fn deflateSetDictionary( + strm: z_streamp, + dictionary: *const Bytef, + dictLength: uInt, + ) -> c_int; + #[link_name = zng_prefix!(deflateSetHeader)] + pub fn deflateSetHeader(strm: z_streamp, head: gz_headerp) -> c_int; + #[link_name = zng_prefix!(deflateTune)] + pub fn deflateTune( + strm: z_streamp, + good_length: c_int, + max_lazy: c_int, + nice_length: c_int, + max_chain: c_int, + ) -> c_int; + #[link_name = zng_prefix!(inflate)] + pub fn inflate(strm: z_streamp, flush: c_int) -> c_int; + #[link_name = zng_prefix!(inflateBack)] + pub fn inflateBack( + strm: z_streamp, + _in: in_func, + in_desc: *mut c_void, + out: out_func, + out_desc: *mut c_void, + ) -> c_int; + #[link_name = zng_prefix!(inflateBackEnd)] + pub fn inflateBackEnd(strm: z_streamp) -> c_int; + #[link_name = zng_prefix!(inflateCopy)] + pub fn inflateCopy(dest: z_streamp, source: z_streamp) -> c_int; + #[link_name = zng_prefix!(inflateEnd)] + pub fn inflateEnd(strm: z_streamp) -> c_int; + #[link_name = zng_prefix!(inflateGetHeader)] + pub fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int; + #[link_name = zng_prefix!(inflateMark)] + pub fn inflateMark(strm: z_streamp) -> c_long; + #[link_name = zng_prefix!(inflatePrime)] + pub fn inflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; + #[link_name = zng_prefix!(inflateReset)] + pub fn inflateReset(strm: z_streamp) -> c_int; + #[link_name = zng_prefix!(inflateReset2)] + pub fn inflateReset2(strm: z_streamp, windowBits: c_int) -> c_int; + #[link_name = zng_prefix!(inflateSetDictionary)] + pub fn inflateSetDictionary( + strm: z_streamp, + dictionary: *const Bytef, + dictLength: uInt, + ) -> c_int; + #[link_name = zng_prefix!(inflateSync)] + pub fn inflateSync(strm: z_streamp) -> c_int; + #[link_name = zng_prefix!(zlibCompileFlags)] + pub fn zlibCompileFlags() -> uLong; + + // The above set of functions currently target 1.2.3.4 (what's present on Ubuntu + // 12.04, but there's some other APIs that were added later. Should figure out + // how to expose them... + // + // Added in 1.2.5.1 + // + // pub fn deflatePending(strm: z_streamp, + // pending: *mut c_uint, + // bits: *mut c_int) -> c_int; + // + // Addedin 1.2.7.1 + // pub fn inflateGetDictionary(strm: z_streamp, + // dictionary: *mut Bytef, + // dictLength: *mut uInt) -> c_int; + // + // Added in 1.2.3.5 + // pub fn gzbuffer(file: gzFile, size: c_uint) -> c_int; + // pub fn gzclose_r(file: gzFile) -> c_int; + // pub fn gzclose_w(file: gzFile) -> c_int; + // pub fn gzoffset(file: gzFile) -> z_off_t; +} + +extern "C" { + #[link_name = if_zng!("zlibng_version", "zlibVersion")] + pub fn zlibVersion() -> *const c_char; +} + +#[cfg(not(zng))] +extern "C" { + pub fn deflateInit_( + strm: z_streamp, + level: c_int, + version: *const c_char, + stream_size: c_int, + ) -> c_int; + pub fn deflateInit2_( + strm: z_streamp, + level: c_int, + method: c_int, + windowBits: c_int, + memLevel: c_int, + strategy: c_int, + version: *const c_char, + stream_size: c_int, + ) -> c_int; + pub fn inflateBackInit_( + strm: z_streamp, + windowBits: c_int, + window: *mut c_uchar, + version: *const c_char, + stream_size: c_int, + ) -> c_int; + pub fn inflateInit_(strm: z_streamp, version: *const c_char, stream_size: c_int) -> c_int; + pub fn inflateInit2_( + strm: z_streamp, + windowBits: c_int, + version: *const c_char, + stream_size: c_int, + ) -> c_int; +} + +#[cfg(zng)] +extern "C" { + pub fn zng_deflateInit(strm: z_streamp, level: c_int) -> c_int; + pub fn zng_deflateInit2( + strm: z_streamp, + level: c_int, + method: c_int, + windowBits: c_int, + memLevel: c_int, + strategy: c_int, + ) -> c_int; + pub fn zng_inflateBackInit(strm: z_streamp, windowBits: c_int, window: *mut c_uchar) -> c_int; + pub fn zng_inflateInit(strm: z_streamp) -> c_int; + pub fn zng_inflateInit2(strm: z_streamp, windowBits: c_int) -> c_int; +} + +// These methods are required to keep BC with original zlib API since zlib-ng 2.1 that changed API +#[cfg(zng)] +#[inline(always)] +pub unsafe fn inflateInit2_( + strm: z_streamp, + windowBits: c_int, + _version: *const c_char, + _stream_size: c_int, +) -> c_int { + zng_inflateInit2(strm, windowBits) +} + +#[cfg(zng)] +#[inline(always)] +pub unsafe fn inflateInit_(strm: z_streamp, _version: *const c_char, _stream_size: c_int) -> c_int { + zng_inflateInit(strm) +} + +#[cfg(zng)] +#[inline(always)] +pub unsafe fn inflateBackInit_( + strm: z_streamp, + windowBits: c_int, + window: *mut c_uchar, + _version: *const c_char, + _stream_size: c_int, +) -> c_int { + zng_inflateBackInit(strm, windowBits, window) +} + +#[cfg(zng)] +#[inline(always)] +pub unsafe fn deflateInit2_( + strm: z_streamp, + level: c_int, + method: c_int, + windowBits: c_int, + memLevel: c_int, + strategy: c_int, + _version: *const c_char, + _stream_size: c_int, +) -> c_int { + zng_deflateInit2(strm, level, method, windowBits, memLevel, strategy) +} + +#[cfg(zng)] +#[inline] +pub unsafe fn deflateInit_( + strm: z_streamp, + level: c_int, + _version: *const c_char, + _stream_size: c_int, +) -> c_int { + zng_deflateInit(strm, level) +} + +#[cfg(any(zng, feature = "libc"))] +extern "C" { + #[link_name = zng_prefix!(adler32_combine)] + pub fn adler32_combine(adler1: z_checksum, adler2: z_checksum, len2: z_off_t) -> z_checksum; + #[link_name = zng_prefix!(compress)] + pub fn compress( + dest: *mut Bytef, + destLen: *mut z_size, + source: *const Bytef, + sourceLen: z_size, + ) -> c_int; + #[link_name = zng_prefix!(compress2)] + pub fn compress2( + dest: *mut Bytef, + destLen: *mut z_size, + source: *const Bytef, + sourceLen: z_size, + level: c_int, + ) -> c_int; + #[link_name = zng_prefix!(compressBound)] + pub fn compressBound(sourceLen: z_size) -> z_size; + #[link_name = zng_prefix!(crc32_combine)] + pub fn crc32_combine(crc1: z_checksum, crc2: z_checksum, len2: z_off_t) -> z_checksum; + #[link_name = zng_prefix!(gzdirect)] + pub fn gzdirect(file: gzFile) -> c_int; + #[link_name = zng_prefix!(gzdopen)] + pub fn gzdopen(fd: c_int, mode: *const c_char) -> gzFile; + #[link_name = zng_prefix!(gzclearerr)] + pub fn gzclearerr(file: gzFile); + #[link_name = zng_prefix!(gzclose)] + pub fn gzclose(file: gzFile) -> c_int; + #[link_name = zng_prefix!(gzeof)] + pub fn gzeof(file: gzFile) -> c_int; + #[link_name = zng_prefix!(gzerror)] + pub fn gzerror(file: gzFile, errnum: *mut c_int) -> *const c_char; + #[link_name = zng_prefix!(gzflush)] + pub fn gzflush(file: gzFile, flush: c_int) -> c_int; + #[link_name = zng_prefix!(gzgetc)] + pub fn gzgetc(file: gzFile) -> c_int; + #[link_name = zng_prefix!(gzgets)] + pub fn gzgets(file: gzFile, buf: *mut c_char, len: c_int) -> *mut c_char; + #[link_name = zng_prefix!(gzopen)] + pub fn gzopen(path: *const c_char, mode: *const c_char) -> gzFile; + #[link_name = zng_prefix!(gzputc)] + pub fn gzputc(file: gzFile, c: c_int) -> c_int; + #[link_name = zng_prefix!(gzputs)] + pub fn gzputs(file: gzFile, s: *const c_char) -> c_int; + #[link_name = zng_prefix!(gzread)] + pub fn gzread(file: gzFile, buf: voidp, len: c_uint) -> c_int; + #[link_name = zng_prefix!(gzrewind)] + pub fn gzrewind(file: gzFile) -> c_int; + #[link_name = zng_prefix!(gzseek)] + pub fn gzseek(file: gzFile, offset: z_off_t, whence: c_int) -> z_off_t; + #[link_name = zng_prefix!(gzsetparams)] + pub fn gzsetparams(file: gzFile, level: c_int, strategy: c_int) -> c_int; + #[link_name = zng_prefix!(gztell)] + pub fn gztell(file: gzFile) -> z_off_t; + #[link_name = zng_prefix!(gzungetc)] + pub fn gzungetc(c: c_int, file: gzFile) -> c_int; + #[link_name = zng_prefix!(gzwrite)] + pub fn gzwrite(file: gzFile, buf: voidpc, len: c_uint) -> c_int; + #[link_name = zng_prefix!(uncompress)] + pub fn uncompress( + dest: *mut Bytef, + destLen: *mut z_size, + source: *const Bytef, + sourceLen: z_size, + ) -> c_int; +} + +pub const Z_NO_FLUSH: c_int = 0; +pub const Z_PARTIAL_FLUSH: c_int = 1; +pub const Z_SYNC_FLUSH: c_int = 2; +pub const Z_FULL_FLUSH: c_int = 3; +pub const Z_FINISH: c_int = 4; +pub const Z_BLOCK: c_int = 5; +pub const Z_TREES: c_int = 6; + +pub const Z_OK: c_int = 0; +pub const Z_STREAM_END: c_int = 1; +pub const Z_NEED_DICT: c_int = 2; +pub const Z_ERRNO: c_int = -1; +pub const Z_STREAM_ERROR: c_int = -2; +pub const Z_DATA_ERROR: c_int = -3; +pub const Z_MEM_ERROR: c_int = -4; +pub const Z_BUF_ERROR: c_int = -5; +pub const Z_VERSION_ERROR: c_int = -6; + +pub const Z_NO_COMPRESSION: c_int = 0; +pub const Z_BEST_SPEED: c_int = 1; +pub const Z_BEST_COMPRESSION: c_int = 9; +pub const Z_DEFAULT_COMPRESSION: c_int = -1; + +pub const Z_FILTERED: c_int = 1; +pub const Z_HUFFMAN_ONLY: c_int = 2; +pub const Z_RLE: c_int = 3; +pub const Z_FIXED: c_int = 4; +pub const Z_DEFAULT_STRATEGY: c_int = 0; + +pub const Z_BINARY: c_int = 0; +pub const Z_TEXT: c_int = 1; +pub const Z_ASCII: c_int = Z_TEXT; +pub const Z_UNKNOWN: c_int = 2; + +pub const Z_DEFLATED: c_int = 8; diff --git a/vendor/libz-sys/src/smoke.c b/vendor/libz-sys/src/smoke.c new file mode 100644 index 0000000..f659aa7 --- /dev/null +++ b/vendor/libz-sys/src/smoke.c @@ -0,0 +1,5 @@ +#include <zlib.h> + +int main() { + return (int) adler32; +} |