Skip to content

Commit 866c282

Browse files
make zip-cli/te mirror the named features on the zip crate
1 parent e3b6661 commit 866c282

File tree

3 files changed

+80
-60
lines changed

3 files changed

+80
-60
lines changed

cli/Cargo.toml

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
[package]
2-
name = "zip-cli"
3-
version = "0.0.1"
4-
authors = [
2+
name = "zip-cli"
3+
version = "0.0.1"
4+
authors = [
55
"Danny McClanahan <[email protected]>",
66
]
7-
license = "MIT"
8-
repository = "https://github.com/zip-rs/zip2.git"
9-
keywords = ["zip", "archive", "compression", "cli"]
10-
categories = ["command-line-utilities", "compression", "filesystem", "development-tools::build-utils"]
7+
license = "MIT"
8+
repository = "https: //github.com/zip-rs/zip2.git"
9+
keywords = ["zip", "archive", "compression", "cli"]
10+
categories = ["command-line-utilities", "compression", "filesystem", "development-tools::build-utils"]
1111
# This field is not as important as in the top-level library API, but as there:
1212
# Any change to rust-version must be reflected also in `README.md` and `.github/workflows/ci.yaml`.
1313
# The MSRV policy is documented in `README.md`.
14-
rust-version = "1.83.0"
15-
description = """
14+
rust-version = "1.83.0"
15+
description = """
1616
Binary for creation and manipulation of zip files.
1717
1818
This package can enable or disable certain dependencies during the build and install process with
1919
cargo features.
2020
"""
21-
edition = "2021"
21+
edition = "2021"
2222

2323
# Prevent this from interfering with workspaces
2424
[workspace]
25-
members = ["."]
25+
members = ["."]
2626

2727
[lib]
2828

2929
[[bin]]
30-
name = "zip-cli"
30+
name = "zip-cli"
3131

3232
[dependencies.zip]
33-
path = ".."
34-
default-features = false
33+
path = ".."
34+
default-features = false
3535

3636
[features]
37-
aes-crypto = ["zip/aes-crypto"]
38-
bzip2 = ["zip/bzip2"]
39-
chrono = ["zip/chrono"]
40-
deflate64 = ["zip/deflate64"]
41-
deflate = ["zip/deflate"]
42-
deflate-flate2 = ["zip/deflate-flate2"]
43-
deflate-flate2-zlib-rs = ["zip/deflate-flate2-zlib-rs"]
44-
deflate-flate2-zlib = ["zip/deflate-flate2-zlib"]
45-
deflate-zopfli = ["zip/deflate-zopfli"]
46-
lzma = ["zip/lzma"]
47-
ppmd = ["zip/ppmd"]
48-
time = ["zip/time"]
49-
xz = ["zip/xz"]
50-
zstd = ["zip/zstd"]
37+
aes-crypto = ["zip/aes-crypto"]
38+
bzip2 = ["zip/bzip2"]
39+
chrono = ["zip/chrono"]
40+
_deflate-any = ["zip/_deflate-any"]
41+
deflate64 = ["zip/deflate64"]
42+
deflate = ["zip/deflate"]
43+
deflate-flate2 = ["zip/deflate-flate2"]
44+
deflate-flate2-zlib-rs = ["zip/deflate-flate2-zlib-rs"]
45+
deflate-flate2-zlib = ["zip/deflate-flate2-zlib"]
46+
deflate-zopfli = ["zip/deflate-zopfli"]
47+
lzma = ["zip/lzma"]
48+
ppmd = ["zip/ppmd"]
49+
time = ["zip/time"]
50+
xz = ["zip/xz"]
51+
zstd = ["zip/zstd"]
5152

52-
default = [
53+
# Generate a highly featureful binary by default.
54+
default = [
5355
"aes-crypto",
5456
"bzip2",
5557
"deflate64",
@@ -62,7 +64,7 @@ default = [
6264
]
6365

6466
[profile.release]
65-
strip = true
66-
lto = true
67-
opt-level = 3
68-
codegen-units = 1
67+
strip = true
68+
lto = true
69+
opt-level = 3
70+
codegen-units = 1

cli/clite/Cargo.toml

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,66 @@
11
[package]
2-
name = "zip-clite"
3-
version = "0.0.1"
4-
authors = [
2+
name = "zip-clite"
3+
version = "0.0.1"
4+
authors = [
55
"Danny McClanahan <[email protected]>",
66
]
7-
license = "MIT"
8-
repository = "https://github.com/zip-rs/zip2.git"
9-
keywords = ["zip", "archive", "compression", "cli"]
10-
categories = ["command-line-utilities", "compression", "filesystem", "development-tools::build-utils"]
7+
license = "MIT"
8+
repository = "https://github.com/zip-rs/zip2.git"
9+
keywords = ["zip", "archive", "compression", "cli"]
10+
categories = ["command-line-utilities", "compression", "filesystem", "development-tools::build-utils"]
1111
# This field is not as important as in the top-level library API, but as there:
1212
# Any change to rust-version must be reflected also in `README.md` and `.github/workflows/ci.yaml`.
1313
# The MSRV policy is documented in `README.md`.
14-
rust-version = "1.83.0"
15-
description = """
14+
rust-version = "1.83.0"
15+
description = """
1616
Binary for creation and manipulation of zip files.
1717
1818
This distribution is created to be intentionally very small and easy to audit. It has reduced
1919
functionality, builds to optimize for size, and only bundles in support for a Rust
2020
DEFLATE implementation.
2121
"""
22-
edition = "2021"
22+
edition = "2021"
2323

2424
# Prevent this from interfering with workspaces
2525
[workspace]
26-
members = ["."]
26+
members = ["."]
2727

2828
[[bin]]
29-
name = "zip-clite"
29+
name = "zip-clite"
3030

3131
# NB: This is not a dependency on the top-level `zip` crate, but the `zip-cli` crate (which mirrors
3232
# the declared features from `zip`). We do not use its `main.rs` entry point, but rely upon
3333
# `lib.rs`, which was specifically designed to minimize the amount of code specific to
3434
# `zip-clite`.
3535
[dependencies.zip-cli]
36-
path = ".."
37-
default-features = false
38-
features = [
39-
"deflate-flate2",
40-
"deflate-flate2-zlib-rs",
41-
]
36+
path = ".."
37+
default-features = false
4238

43-
# No features, no options, no decisions! We're just making it explicit.
4439
[features]
45-
default = []
40+
aes-crypto = ["zip-cli/aes-crypto"]
41+
bzip2 = ["zip-cli/bzip2"]
42+
chrono = ["zip-cli/chrono"]
43+
_deflate-any = ["zip-cli/_deflate-any"]
44+
deflate64 = ["zip-cli/deflate64"]
45+
deflate = ["zip-cli/deflate"]
46+
deflate-flate2 = ["zip-cli/deflate-flate2"]
47+
deflate-flate2-zlib-rs = ["zip-cli/deflate-flate2-zlib-rs"]
48+
deflate-flate2-zlib = ["zip-cli/deflate-flate2-zlib"]
49+
deflate-zopfli = ["zip-cli/deflate-zopfli"]
50+
lzma = ["zip-cli/lzma"]
51+
ppmd = ["zip-cli/ppmd"]
52+
time = ["zip-cli/time"]
53+
xz = ["zip-cli/xz"]
54+
zstd = ["zip-cli/zstd"]
55+
56+
# Only bring in the pure-Rust DEFLATE implementation by default.
57+
default = [
58+
"deflate-flate2",
59+
"deflate-flate2-zlib-rs",
60+
]
4661

4762
[profile.release]
48-
strip = true
49-
lto = true
50-
opt-level = "s"
51-
codegen-units = 1
63+
strip = true
64+
lto = true
65+
opt-level = "s"
66+
codegen-units = 1

cli/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ fn compress(this: String, mut args: VecDeque<ffi::OsString>) -> ! {
106106
};
107107

108108
let stored = SimpleFileOptions::default().compression_method(CompressionMethod::Stored);
109-
let compressed = SimpleFileOptions::default()
110-
.compression_method(CompressionMethod::Deflated)
111-
.compression_level(Some(9));
109+
let compressed = zip::cfg_if_expr! {
110+
#[cfg(feature = "_deflate-any")] => SimpleFileOptions::default()
111+
.compression_method(CompressionMethod::Deflated)
112+
.compression_level(Some(9)),
113+
_ => stored,
114+
};
112115
for line in io::stdin().lines() {
113116
let line = line.unwrap();
114117
let p = path::Path::new(&line);

0 commit comments

Comments
 (0)