Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ jobs:
- run: |
cargo test --no-default-features --features zlib-ng-no-cmake-experimental-community-maintained || echo "::warning::failed to build libz-ng with --features zlib-ng-no-cmake-experimental-community-maintained"
cargo run --manifest-path systest/Cargo.toml --no-default-features --features zlib-ng-no-cmake-experimental-community-maintained || echo "::warning::failed to run systest with --features zlib-ng-no-cmake-experimental-community-maintained"


# ensures packaging works
package:
Expand All @@ -106,10 +105,13 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- run: |
- name: test bare packaging
run: |
cargo package --all-features
cargo package --no-default-features --features zlib-ng-no-cmake-experimental-community-maintained
cargo package --no-default-features --features zlib-ng
- name: test packaging with release tool
run: cargo run -p maint -- publish

linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -158,7 +160,6 @@ jobs:
- run: cargo build --features zlib-ng --no-default-features
- run: cargo build --no-default-features --features zlib-ng-no-cmake-experimental-community-maintained || echo "::warning::failed to build libz-ng with --features zlib-ng-no-cmake-experimental-community-maintained"


strategy:
fail-fast: false
matrix:
Expand Down
6 changes: 4 additions & 2 deletions Cargo-zng.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libz-ng-sys"
version = "1.1.27"
version = "1.1.28"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Josh Triplett <josh@joshtriplett.org>",
Expand All @@ -17,10 +17,12 @@ edition = "2018"
exclude = [
"/.github",
"/.gitmodules",
"/MAINTENANCE.md",
"/README.md",
"/build.rs",
"/cargo-zng",
"/ci",
"/maint",
"/src/smoke.c",
"/src/zlib",
"/systest",
Expand All @@ -39,4 +41,4 @@ libc = "0.2.43"
cmake = "0.1.50"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(zng)'] }
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(zng)', 'cfg(feature, values("libc"))'] }
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libz-sys"
version = "1.1.27"
version = "1.1.28"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Josh Triplett <josh@joshtriplett.org>",
Expand Down Expand Up @@ -45,7 +45,7 @@ include = [
]

[workspace]
members = ["systest"]
members = ["maint", "systest"]

[dependencies]
# When this feature is disabled, zlib will be built in Z_SOLO mode which
Expand Down
65 changes: 65 additions & 0 deletions MAINTENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Maintenance Guide

This repository publishes two crates from the same sources:

- `libz-sys`, from [`Cargo.toml`](Cargo.toml)
- `libz-ng-sys`, from [`Cargo-zng.toml`](Cargo-zng.toml)

The supported release entrypoint is the maintenance tool in `maint/`.

## Release Steps

1. Update both crate versions so that `Cargo.toml` and `Cargo-zng.toml` have
the exact same `package.version`.
2. Make sure the release commit is checked out with submodules initialized.
3. Run the release verification in dry-run mode:

```bash
cargo run -p maint -- publish
```

This verifies all release packaging and build combinations with
`cargo publish --dry-run`, checks that both manifests have the same version,
and rejects missing bundled source files or missing packaged source files.

4. Perform the actual publish only after the dry-run passes:

```bash
cargo run -p maint -- publish --execute
```

The tool verifies first, then publishes `libz-sys` and `libz-ng-sys`.

5. Create and push the Git tag after both publishes succeed. `maint` provides instructions.

## Safety Rules

- `maint publish` defaults to dry-run mode. Real publishing requires
`--execute`.
- The tool never relies on a bare `cargo publish`. Verification always uses
`cargo publish --dry-run`, and the upload step uses `cargo publish --no-verify`
only after all dry-run checks succeed.
- The release path does not use `--allow-dirty`; Cargo should reject a dirty
worktree.
- Missing submodule checkouts are caught before publishing by requiring bundled
zlib and zlib-ng source files to exist in the worktree and in the packaged
crate contents.

## Working on `libz-ng-sys`

Use the maint tool to run Cargo as if the repository were checked out as the
`libz-ng-sys` crate:

```bash
cargo run -p maint -- zng test
```

The compatibility wrapper still works:

```bash
./cargo-zng test
```

If you invoke `publish` through the `zng` command, the tool forces
`--dry-run`. Real publishing is only supported through `maint publish
--execute`.
10 changes: 7 additions & 3 deletions README-zng.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ implementations.
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`.
manifest for `libz-ng-sys`. Use `cargo run -p maint -- zng <cargo-args>` to
run Cargo against a temporary `libz-ng-sys` staging tree. The `./cargo-zng`
script remains as a compatibility wrapper around that command.

Use `cargo run -p maint -- publish` to verify the release in dry-run mode, and
`cargo run -p maint -- publish --execute` to publish both crates. See
[`MAINTENANCE.md`](MAINTENANCE.md) for the full release process.

# Minimum Supported Rust Version (MSRV) Policy

Expand Down
47 changes: 23 additions & 24 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ fn main() {
// 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.)
if !want_static &&
!target.contains("msvc") && // pkg-config just never works here
!(host_and_target_contain("freebsd") ||
host_and_target_contain("dragonfly"))
if !(want_static
// pkg-config just never works here
|| target.contains("msvc")
|| 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
Expand All @@ -59,15 +60,16 @@ fn main() {
}
}
Err(e) => {
println!("cargo:warning=Could not find zlib include paths via pkg-config: {}", e)
println!(
"cargo:warning=Could not find zlib include paths via pkg-config: {}",
e
)
}
}
}

if target.contains("windows") {
if try_vcpkg() {
return;
}
if target.contains("windows") && try_vcpkg() {
return;
}

let mut cfg = cc::Build::new();
Expand All @@ -77,10 +79,7 @@ fn main() {
// - MSVC basically never has zlib preinstalled
// - MinGW picks up a bunch of weird paths we don't like
// - Explicit opt-in via `want_static`
if target.contains("msvc")
|| target.contains("pc-windows-gnu")
|| want_static
{
if target.contains("msvc") || target.contains("pc-windows-gnu") || want_static {
return build_zlib(&mut cfg, &target);
}

Expand Down Expand Up @@ -117,7 +116,7 @@ fn build_zlib(cfg: &mut cc::Build, target: &str) {
.file("src/zlib/uncompr.c")
.file("src/zlib/zutil.c");

if !cfg!(feature = "libc") || target.starts_with("wasm32") {
if target.starts_with("wasm32") {
cfg.define("Z_SOLO", None);
// zlib 1.3.2 uses `NULL` directly in compress.c/uncompr.c, but the
// Z_SOLO config path doesn't pull in headers that always define it.
Expand Down Expand Up @@ -243,15 +242,15 @@ fn zlib_installed(cfg: &mut cc::Build) -> bool {
/// this enables the build environment to revert that preference via `LIBZ_SYS_STATIC=0`.
/// The default is otherwise `false`.
fn should_link_static() -> bool {
let has_static_env: Option<&'static str> = option_env!("LIBZ_SYS_STATIC");
let has_static_cfg = cfg!(feature = "static");
let has_static_env: Option<&'static str> = option_env!("LIBZ_SYS_STATIC");
let has_static_cfg = cfg!(feature = "static");

has_static_env
.and_then(|s: &str| s.parse::<u8>().ok())
.and_then(|b| match b {
0 => Some(false),
1 => Some(true),
_ => None,
})
.unwrap_or(has_static_cfg)
has_static_env
.and_then(|s: &str| s.parse::<u8>().ok())
.and_then(|b| match b {
0 => Some(false),
1 => Some(true),
_ => None,
})
.unwrap_or(has_static_cfg)
}
15 changes: 2 additions & 13 deletions cargo-zng
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#!/bin/bash
set -eu
tempdir="$(mktemp -d)"
trap 'rm -rf "$tempdir"' 0 INT
cargo package -l --allow-dirty |
tr '\\' '/' |
grep -vxF -e Cargo.toml.orig -e .cargo_vcs_info.json -e Cargo.lock |
tar --files-from=- -cf - |
tar -C "$tempdir" -xf -
cp Cargo-zng.toml "$tempdir/Cargo.toml"
cp -a systest "$tempdir/systest"
mv "$tempdir/systest/Cargo-zng.toml" "$tempdir/systest/Cargo.toml"
cd "$tempdir"
cargo "$@"
set -euo pipefail
exec cargo run --quiet -p maint -- zng "$@"
10 changes: 10 additions & 0 deletions maint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "maint"
version = "0.1.0"
edition = "2024"
publish = false

[dependencies]
anyhow = "1.0.100"
tempfile = "3.23.0"
toml = "0.9.7"
Loading
Loading