Skip to content

Commit

Permalink
Clean up the backend-specific code a little, remove libc entirely for…
Browse files Browse the repository at this point in the history
… rust backend
  • Loading branch information
oyvindln committed Aug 7, 2019
1 parent 344f58b commit b561eb6
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 342 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ streams.
members = ['systest']

[dependencies]
libc = "0.2"
libc = { version = "0.2", optional = true }
miniz-sys = { path = "miniz-sys", version = "0.1.11", optional = true }
libz-sys = { version = "1.0", optional = true }
tokio-io = { version = "0.1.11", optional = true }
Expand All @@ -37,8 +37,8 @@ tokio-threadpool = "0.1.10"
futures = "0.1"

[features]
default = ["miniz-sys"]
zlib = ["libz-sys"]
default = ["miniz-sys", "libc"]
zlib = ["libz-sys", "libc"]
rust_backend = ["miniz_oxide"]
tokio = ["tokio-io", "futures"]

Expand Down
4 changes: 0 additions & 4 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ mod imp {
StreamWrapper::None
}
}

/// Dummy
#[allow(non_camel_case_types)]
pub struct mz_stream {}
}

#[cfg(all(
Expand Down
21 changes: 4 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@
extern crate crc32fast;
#[cfg(feature = "tokio")]
extern crate futures;
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
#[cfg(not(any(
all(not(feature = "zlib"), feature = "rust_backend"),
all(target_arch = "wasm32", not(target_os = "emscripten"))
)))]
extern crate libc;
#[cfg(test)]
extern crate quickcheck;
Expand All @@ -91,22 +94,6 @@ extern crate rand;
#[cfg(feature = "tokio")]
extern crate tokio_io;

// These must currently agree with here --
// https://github.com/Frommi/miniz_oxide/blob/e6c214efd253491ac072c2c9adba87ef5b4cd5cb/src/lib.rs#L14-L19
//
// Eventually we'll want to actually move these into `libc` itself for wasm, or
// otherwise not use the capi crate for miniz_oxide but rather use the
// underlying types.
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
mod libc {
#![allow(non_camel_case_types)]
pub type c_ulong = u64;
pub type off_t = i64;
pub type c_int = i32;
pub type c_uint = u32;
pub type size_t = usize;
}

pub use crc::{Crc, CrcReader, CrcWriter};
pub use gz::GzBuilder;
pub use gz::GzHeader;
Expand Down
Loading

0 comments on commit b561eb6

Please sign in to comment.