mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
chore(ext/node): use libz-sys w/zlib-ng
feature in node (#21158)
We only want one zlib dependency. Zlib dependencies are reorganized so they use a hidden `__vendored_zlib_ng` flag in cli that enables zlib-ng for both libz-sys (used by ext/node) and flate2 (used by deno_web).
This commit is contained in:
parent
0c1ab2c7f7
commit
56e76242f3
10 changed files with 50 additions and 51 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -925,6 +925,7 @@ dependencies = [
|
||||||
"junction",
|
"junction",
|
||||||
"lazy-regex",
|
"lazy-regex",
|
||||||
"libc",
|
"libc",
|
||||||
|
"libz-sys",
|
||||||
"log",
|
"log",
|
||||||
"lsp-types",
|
"lsp-types",
|
||||||
"monch",
|
"monch",
|
||||||
|
@ -1552,6 +1553,7 @@ dependencies = [
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"fastwebsockets",
|
"fastwebsockets",
|
||||||
"filetime",
|
"filetime",
|
||||||
|
"flate2",
|
||||||
"fs3",
|
"fs3",
|
||||||
"fwdansi",
|
"fwdansi",
|
||||||
"http",
|
"http",
|
||||||
|
@ -2338,7 +2340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
|
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"libz-ng-sys",
|
"libz-sys",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3132,16 +3134,6 @@ dependencies = [
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libz-ng-sys"
|
|
||||||
version = "1.1.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3dd9f43e75536a46ee0f92b758f6b63846e594e86638c61a9251338a65baea63"
|
|
||||||
dependencies = [
|
|
||||||
"cmake",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libz-sys"
|
name = "libz-sys"
|
||||||
version = "1.1.12"
|
version = "1.1.12"
|
||||||
|
@ -3149,6 +3141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b"
|
checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
|
"cmake",
|
||||||
"libc",
|
"libc",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
|
|
|
@ -96,7 +96,7 @@ encoding_rs = "=0.8.33"
|
||||||
ecb = "=0.1.2"
|
ecb = "=0.1.2"
|
||||||
fastwebsockets = "=0.5.0"
|
fastwebsockets = "=0.5.0"
|
||||||
filetime = "0.2.16"
|
filetime = "0.2.16"
|
||||||
flate2 = { version = "1.0.26", features = ["zlib-ng"], default-features = false }
|
flate2 = { version = "1.0.26", default-features = false }
|
||||||
fs3 = "0.5.0"
|
fs3 = "0.5.0"
|
||||||
futures = "0.3.21"
|
futures = "0.3.21"
|
||||||
glob = "0.3.1"
|
glob = "0.3.1"
|
||||||
|
@ -107,6 +107,7 @@ httparse = "1.8.0"
|
||||||
hyper = { version = "0.14.26", features = ["runtime", "http1"] }
|
hyper = { version = "0.14.26", features = ["runtime", "http1"] }
|
||||||
indexmap = { version = "2", features = ["serde"] }
|
indexmap = { version = "2", features = ["serde"] }
|
||||||
libc = "0.2.126"
|
libc = "0.2.126"
|
||||||
|
libz-sys = { version = "1.1", default-features = false }
|
||||||
log = "=0.4.20"
|
log = "=0.4.20"
|
||||||
lsp-types = "=0.94.1" # used by tower-lsp and "proposed" feature is unstable in patch releases
|
lsp-types = "=0.94.1" # used by tower-lsp and "proposed" feature is unstable in patch releases
|
||||||
memmem = "0.1.1"
|
memmem = "0.1.1"
|
||||||
|
|
|
@ -27,9 +27,12 @@ harness = false
|
||||||
path = "./bench/lsp_bench_standalone.rs"
|
path = "./bench/lsp_bench_standalone.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = ["__vendored_zlib_ng"]
|
||||||
# A dev feature to disable creations and loading of snapshots in favor of
|
# A dev feature to disable creations and loading of snapshots in favor of
|
||||||
# loading JS sources at runtime.
|
# loading JS sources at runtime.
|
||||||
__runtime_js_sources = ["deno_runtime/__runtime_js_sources"]
|
__runtime_js_sources = ["deno_runtime/__runtime_js_sources"]
|
||||||
|
# Vendor zlib as zlib-ng
|
||||||
|
__vendored_zlib_ng = ["flate2/zlib-ng-compat", "libz-sys/zlib-ng"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
deno_runtime = { workspace = true, features = ["exclude_runtime_main_js", "include_js_files_for_snapshotting"] }
|
deno_runtime = { workspace = true, features = ["exclude_runtime_main_js", "include_js_files_for_snapshotting"] }
|
||||||
|
@ -39,6 +42,7 @@ serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
zstd.workspace = true
|
zstd.workspace = true
|
||||||
glibc_version = "0.1.2"
|
glibc_version = "0.1.2"
|
||||||
|
flate2 = { workspace = true, features = ["default"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
winapi.workspace = true
|
winapi.workspace = true
|
||||||
|
@ -84,6 +88,7 @@ encoding_rs.workspace = true
|
||||||
env_logger = "=0.10.0"
|
env_logger = "=0.10.0"
|
||||||
fancy-regex = "=0.10.0"
|
fancy-regex = "=0.10.0"
|
||||||
fastwebsockets.workspace = true
|
fastwebsockets.workspace = true
|
||||||
|
# If you disable the default __vendored_zlib_ng feature above, you _must_ be able to link against `-lz`.
|
||||||
flate2.workspace = true
|
flate2.workspace = true
|
||||||
fs3.workspace = true
|
fs3.workspace = true
|
||||||
glob = "0.3.1"
|
glob = "0.3.1"
|
||||||
|
@ -95,6 +100,7 @@ indexmap.workspace = true
|
||||||
jsonc-parser = { version = "=0.21.1", features = ["serde"] }
|
jsonc-parser = { version = "=0.21.1", features = ["serde"] }
|
||||||
lazy-regex.workspace = true
|
lazy-regex.workspace = true
|
||||||
libc.workspace = true
|
libc.workspace = true
|
||||||
|
libz-sys.workspace = true
|
||||||
log = { workspace = true, features = ["serde"] }
|
log = { workspace = true, features = ["serde"] }
|
||||||
lsp-types.workspace = true
|
lsp-types.workspace = true
|
||||||
monch.workspace = true
|
monch.workspace = true
|
||||||
|
|
|
@ -41,7 +41,7 @@ indexmap.workspace = true
|
||||||
k256 = "0.13.1"
|
k256 = "0.13.1"
|
||||||
lazy-regex.workspace = true
|
lazy-regex.workspace = true
|
||||||
libc.workspace = true
|
libc.workspace = true
|
||||||
libz-sys = { version = "1.1.8", features = ["static"] }
|
libz-sys.workspace = true
|
||||||
md-5 = "0.10.5"
|
md-5 = "0.10.5"
|
||||||
md4 = "0.10.2"
|
md4 = "0.10.2"
|
||||||
num-bigint.workspace = true
|
num-bigint.workspace = true
|
||||||
|
|
|
@ -18,6 +18,8 @@ use deno_fs::sync::MaybeSend;
|
||||||
use deno_fs::sync::MaybeSync;
|
use deno_fs::sync::MaybeSync;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
extern crate libz_sys as zlib;
|
||||||
|
|
||||||
pub mod analyze;
|
pub mod analyze;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
mod global;
|
mod global;
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::bad_resource_id;
|
use deno_core::error::bad_resource_id;
|
||||||
use deno_core::error::type_error;
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op2;
|
use deno_core::op2;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use libz_sys::*;
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use zlib::*;
|
||||||
|
|
||||||
mod alloc;
|
mod alloc;
|
||||||
pub mod brotli;
|
pub mod brotli;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use libz_sys as sys;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
BadArgument,
|
BadArgument,
|
||||||
|
@ -60,12 +58,12 @@ repr_i32! {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
||||||
pub enum Flush {
|
pub enum Flush {
|
||||||
#[default]
|
#[default]
|
||||||
None = sys::Z_NO_FLUSH,
|
None = zlib::Z_NO_FLUSH,
|
||||||
Partial = sys::Z_PARTIAL_FLUSH,
|
Partial = zlib::Z_PARTIAL_FLUSH,
|
||||||
Sync = sys::Z_SYNC_FLUSH,
|
Sync = zlib::Z_SYNC_FLUSH,
|
||||||
Full = sys::Z_FULL_FLUSH,
|
Full = zlib::Z_FULL_FLUSH,
|
||||||
Finish = sys::Z_FINISH,
|
Finish = zlib::Z_FINISH,
|
||||||
Block = sys::Z_BLOCK,
|
Block = zlib::Z_BLOCK,
|
||||||
Trees = sys::Z_TREES,
|
Trees = zlib::Z_TREES,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,18 @@
|
||||||
|
|
||||||
use super::mode::Flush;
|
use super::mode::Flush;
|
||||||
use super::mode::Mode;
|
use super::mode::Mode;
|
||||||
use libz_sys as sys;
|
|
||||||
use std::ffi::c_int;
|
use std::ffi::c_int;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
|
||||||
pub struct StreamWrapper {
|
pub struct StreamWrapper {
|
||||||
pub strm: sys::z_stream,
|
pub strm: zlib::z_stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for StreamWrapper {
|
impl Default for StreamWrapper {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
strm: sys::z_stream {
|
strm: zlib::z_stream {
|
||||||
next_in: std::ptr::null_mut(),
|
next_in: std::ptr::null_mut(),
|
||||||
avail_in: 0,
|
avail_in: 0,
|
||||||
total_in: 0,
|
total_in: 0,
|
||||||
|
@ -25,7 +24,7 @@ impl Default for StreamWrapper {
|
||||||
state: std::ptr::null_mut(),
|
state: std::ptr::null_mut(),
|
||||||
zalloc: super::alloc::zalloc,
|
zalloc: super::alloc::zalloc,
|
||||||
zfree: super::alloc::zfree,
|
zfree: super::alloc::zfree,
|
||||||
opaque: 0 as sys::voidpf,
|
opaque: 0 as zlib::voidpf,
|
||||||
data_type: 0,
|
data_type: 0,
|
||||||
adler: 0,
|
adler: 0,
|
||||||
reserved: 0,
|
reserved: 0,
|
||||||
|
@ -35,7 +34,7 @@ impl Default for StreamWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for StreamWrapper {
|
impl Deref for StreamWrapper {
|
||||||
type Target = sys::z_stream;
|
type Target = zlib::z_stream;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.strm
|
&self.strm
|
||||||
|
@ -50,14 +49,14 @@ impl DerefMut for StreamWrapper {
|
||||||
|
|
||||||
impl StreamWrapper {
|
impl StreamWrapper {
|
||||||
pub fn reset(&mut self, mode: Mode) -> c_int {
|
pub fn reset(&mut self, mode: Mode) -> c_int {
|
||||||
// SAFETY: `self.strm` is an initialized `z_stream`.
|
// SAFETY: `self.strm` is an initialized `zlib::z_stream`.
|
||||||
unsafe {
|
unsafe {
|
||||||
match mode {
|
match mode {
|
||||||
Mode::Deflate | Mode::Gzip | Mode::DeflateRaw => {
|
Mode::Deflate | Mode::Gzip | Mode::DeflateRaw => {
|
||||||
sys::deflateReset(&mut self.strm)
|
zlib::deflateReset(&mut self.strm)
|
||||||
}
|
}
|
||||||
Mode::Inflate | Mode::Gunzip | Mode::InflateRaw | Mode::Unzip => {
|
Mode::Inflate | Mode::Gunzip | Mode::InflateRaw | Mode::Unzip => {
|
||||||
sys::inflateReset(&mut self.strm)
|
zlib::inflateReset(&mut self.strm)
|
||||||
}
|
}
|
||||||
Mode::None => unreachable!(),
|
Mode::None => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -65,14 +64,14 @@ impl StreamWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn end(&mut self, mode: Mode) {
|
pub fn end(&mut self, mode: Mode) {
|
||||||
// SAFETY: `self.strm` is an initialized `z_stream`.
|
// SAFETY: `self.strm` is an initialized `zlib::z_stream`.
|
||||||
unsafe {
|
unsafe {
|
||||||
match mode {
|
match mode {
|
||||||
Mode::Deflate | Mode::Gzip | Mode::DeflateRaw => {
|
Mode::Deflate | Mode::Gzip | Mode::DeflateRaw => {
|
||||||
sys::deflateEnd(&mut self.strm);
|
zlib::deflateEnd(&mut self.strm);
|
||||||
}
|
}
|
||||||
Mode::Inflate | Mode::Gunzip | Mode::InflateRaw | Mode::Unzip => {
|
Mode::Inflate | Mode::Gunzip | Mode::InflateRaw | Mode::Unzip => {
|
||||||
sys::inflateEnd(&mut self.strm);
|
zlib::inflateEnd(&mut self.strm);
|
||||||
}
|
}
|
||||||
Mode::None => {}
|
Mode::None => {}
|
||||||
}
|
}
|
||||||
|
@ -86,47 +85,47 @@ impl StreamWrapper {
|
||||||
mem_level: c_int,
|
mem_level: c_int,
|
||||||
strategy: c_int,
|
strategy: c_int,
|
||||||
) -> c_int {
|
) -> c_int {
|
||||||
// SAFETY: `self.strm` is an initialized `z_stream`.
|
// SAFETY: `self.strm` is an initialized `zlib::z_stream`.
|
||||||
unsafe {
|
unsafe {
|
||||||
sys::deflateInit2_(
|
zlib::deflateInit2_(
|
||||||
&mut self.strm,
|
&mut self.strm,
|
||||||
level,
|
level,
|
||||||
sys::Z_DEFLATED,
|
zlib::Z_DEFLATED,
|
||||||
window_bits,
|
window_bits,
|
||||||
mem_level,
|
mem_level,
|
||||||
strategy,
|
strategy,
|
||||||
sys::zlibVersion(),
|
zlib::zlibVersion(),
|
||||||
std::mem::size_of::<sys::z_stream>() as i32,
|
std::mem::size_of::<zlib::z_stream>() as i32,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inflate_init(&mut self, window_bits: c_int) -> c_int {
|
pub fn inflate_init(&mut self, window_bits: c_int) -> c_int {
|
||||||
// SAFETY: `self.strm` is an initialized `z_stream`.
|
// SAFETY: `self.strm` is an initialized `zlib::z_stream`.
|
||||||
unsafe {
|
unsafe {
|
||||||
sys::inflateInit2_(
|
zlib::inflateInit2_(
|
||||||
&mut self.strm,
|
&mut self.strm,
|
||||||
window_bits,
|
window_bits,
|
||||||
sys::zlibVersion(),
|
zlib::zlibVersion(),
|
||||||
std::mem::size_of::<sys::z_stream>() as i32,
|
std::mem::size_of::<zlib::z_stream>() as i32,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deflate(&mut self, flush: Flush) -> c_int {
|
pub fn deflate(&mut self, flush: Flush) -> c_int {
|
||||||
// SAFETY: `self.strm` is an initialized `z_stream`.
|
// SAFETY: `self.strm` is an initialized `zlib::z_stream`.
|
||||||
unsafe { sys::deflate(&mut self.strm, flush as _) }
|
unsafe { zlib::deflate(&mut self.strm, flush as _) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inflate(&mut self, flush: Flush) -> c_int {
|
pub fn inflate(&mut self, flush: Flush) -> c_int {
|
||||||
// SAFETY: `self.strm` is an initialized `z_stream`.
|
// SAFETY: `self.strm` is an initialized `zlib::z_stream`.
|
||||||
unsafe { sys::inflate(&mut self.strm, flush as _) }
|
unsafe { zlib::inflate(&mut self.strm, flush as _) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inflate_set_dictionary(&mut self, dictionary: &[u8]) -> c_int {
|
pub fn inflate_set_dictionary(&mut self, dictionary: &[u8]) -> c_int {
|
||||||
// SAFETY: `self.strm` is an initialized `z_stream`.
|
// SAFETY: `self.strm` is an initialized `zlib::z_stream`.
|
||||||
unsafe {
|
unsafe {
|
||||||
sys::inflateSetDictionary(
|
zlib::inflateSetDictionary(
|
||||||
&mut self.strm,
|
&mut self.strm,
|
||||||
dictionary.as_ptr() as *const _,
|
dictionary.as_ptr() as *const _,
|
||||||
dictionary.len() as _,
|
dictionary.len() as _,
|
||||||
|
|
|
@ -61,6 +61,7 @@ deno_webidl.workspace = true
|
||||||
deno_websocket.workspace = true
|
deno_websocket.workspace = true
|
||||||
deno_webstorage.workspace = true
|
deno_webstorage.workspace = true
|
||||||
deno_napi.workspace = true
|
deno_napi.workspace = true
|
||||||
|
flate2 = { workspace = true, features = ["default"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
winres.workspace = true
|
winres.workspace = true
|
||||||
|
|
|
@ -21,7 +21,7 @@ bytes.workspace = true
|
||||||
console_static_text.workspace = true
|
console_static_text.workspace = true
|
||||||
denokv_proto.workspace = true
|
denokv_proto.workspace = true
|
||||||
fastwebsockets = { workspace = true, features = ["upgrade"] }
|
fastwebsockets = { workspace = true, features = ["upgrade"] }
|
||||||
flate2.workspace = true
|
flate2 = { workspace = true, features = ["default"] }
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
glob.workspace = true
|
glob.workspace = true
|
||||||
h2.workspace = true
|
h2.workspace = true
|
||||||
|
|
Loading…
Reference in a new issue