Skip to content

fix(libcups3): adapt existing API to CUPS 3 - #19

Merged
tillkamppeter merged 3 commits into
OpenPrinting:mainfrom
Abd002:adapt-libcups3
Sep 11, 2026
Merged

tillkamppeter merged 3 commits into
OpenPrinting:mainfrom
Abd002:adapt-libcups3

Conversation

@Abd002

@Abd002 Abd002 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

PR Description

This PR updates cups-rs so the existing API builds and works with libcups 3.

The change is limited to adapting the current wrappers to libcups 3 API/signature changes.

Changes

  • Regenerate bindings against libcups 3.
  • Update renamed CUPS constants and enum values.
  • Adapt libcups boolean/count/index arguments to the CUPS 3 signatures.
  • Replace removed CUPS media-size type usage with the current media type.
  • Remove obsolete CUPS 2 compatibility checks.
  • Keep the public API behavior focused on the existing crate functionality.

Requirements

This PR requires libcups 3. For local testing, libcups 3 can be built from OpenPrinting/libcups:

git clone --recurse-submodules https://github.com/OpenPrinting/libcups.git
cd libcups
./configure \
  --prefix=/usr/local \
  --with-domainsocket=/run/cups/cups.sock
make -j"$(nproc)"
sudo make install
sudo ldconfig

Testing

Tested with libcups 3:

cargo fmt --all -- --check
cargo check --all-targets
cargo test --all-targets --quiet

@Abd002

Abd002 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

I updated the branch so cups-rs can now build with either CUPS 2 or CUPS 3.

How it works:

  • build.rs checks pkg-config for libcups.
  • By default it tries cups3 first.
  • If cups3 is not available, it falls back to the normal cups pkg-config package.
  • It then sets either cfg(cups3) or cfg(cups2) for the Rust code.
  • The version-specific C API differences are hidden in small compatibility paths, so the public Rust API stays the same.

For testing a specific version:

CUPS 3:
cargo check --all-targets --features force-cups3

CUPS 2:
cargo check --all-targets --features force-cups2

The force features are only for testing/packaging when we want to make sure a specific CUPS version is used. Normal users do not need to enable anything.

If no feature is added, the build still works automatically:

  • uses CUPS 3 if cups3.pc exists
  • otherwise uses CUPS 2 if cups.pc exists

@tillkamppeter
tillkamppeter merged commit 093d51a into OpenPrinting:main Sep 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants