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
54 changes: 42 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,54 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
vendored-build:
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Build the crate (Unix)
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
run: cargo build --all-features
- name: Build the crate (MSVC)
if: matrix.os == 'windows-latest'
# libcdio-paranoia does not support MSVC
run: cargo build --features iso9660,udf,vendored

non-vendored-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install libcdio
- uses: actions/checkout@v7
with:
submodules: true
- name: Install build dependencies
run: sudo apt install help2man
- name: Build and install libcdio from source
env:
CFLAGS: -O0
run: |
sudo apt-get update
sudo apt-get install -y libcdio-dev libiso9660-dev libudf-dev libcdio-cdda-dev libcdio-paranoia-dev
- uses: dtolnay/rust-toolchain@stable
- run: cargo build --workspace --all-targets --all-features
cd vendor/libcdio
./autogen.sh
make
sudo make install
- name: Build and install libcdio-paranoia from source
run: |
cd vendor/libcdio-paranoia
./autogen.sh
make
sudo make install
- name: Build the crate
run: LIBCDIO_NO_VENDOR=1 cargo build --all-features

semver-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install libcdio
run: |
sudo apt-get update
sudo apt-get install -y libcdio-dev libiso9660-dev libudf-dev libcdio-cdda-dev libcdio-paranoia-dev
- uses: actions/checkout@v7
with:
submodules: true
# Will use a vendored build
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "vendor/libcdio"]
path = vendor/libcdio
url = https://github.com/libcdio/libcdio.git
[submodule "vendor/libcdio-paranoia"]
path = vendor/libcdio-paranoia
url = https://github.com/libcdio/libcdio-paranoia.git
2 changes: 2 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
edition = "2024"
Comment thread
MonterraByte marked this conversation as resolved.
style_edition = "2024"
24 changes: 17 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
[package]
name = "libcdio-sys"
version = "2.0.0"
version = "3.0.0+2.4.0p2.0.2"
edition = "2024"
authors = ["Joaquim Monteiro <joaquim.monteiro@protonmail.com>"]
description = "Native bindings to the libcdio (and libcdio-paranoia) library"
repository = "https://github.com/MonterraByte/libcdio-sys"
readme = "README.md"
exclude = ["/.github"]
exclude = [
"/.github",
"vendor/libcdio/*",
"!vendor/libcdio/.vs/unistd.h",
"!vendor/libcdio/COPYING",
"!vendor/libcdio/include/**/*.h",
"!vendor/libcdio/lib/**/*.[ch]",
]
keywords = ["ffi", "cd", "cdio", "iso9660", "udf"]
categories = ["external-ffi-bindings", "hardware-support", "multimedia", "multimedia::audio"]
license = "GPL-3.0+"
links = "cdio"

[build-dependencies]
bindgen = "0.72"
cc = { version = "1.4.0" }
system-deps = "7"

[features]
Expand All @@ -22,13 +30,15 @@ iso9660 = []
udf = []
cdda = []
paranoia = ["cdda"]
vendored = []

# Do not forget vendor/*version.h
[package.metadata.system-deps]
libcdio = "0"
libiso9660 = { version = "0", feature = "iso9660" }
libudf = { version = "0", feature = "udf" }
libcdio_cdda = { version = "0", feature = "cdda" }
libcdio_paranoia = { version = "0", feature = "paranoia" }
libcdio = ">= 2.4.0, < 3.0.0"
libiso9660 = { version = ">= 2.4.0, < 3.0.0", feature = "iso9660" }
libudf = { version = ">= 2.4.0, < 3.0.0", feature = "udf" }
libcdio_cdda = { version = ">= 10.2+2.0.2, < 10.2+3.0.0", feature = "cdda" }
libcdio_paranoia = { version = ">= 10.2+2.0.2, < 10.2+3.0.0", feature = "paranoia" }

[package.metadata.docs.rs]
all-features = true
46 changes: 34 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# libcdio-sys

Native bindings to the libcdio and libcdio-paranoia libraries

[![crates.io](https://img.shields.io/crates/v/libcdio-sys.svg)](https://crates.io/crates/libcdio-sys)
Expand All @@ -9,18 +8,40 @@ Native bindings to the libcdio and libcdio-paranoia libraries
[libcdio documentation](https://www.gnu.org/software/libcdio/libcdio.html)

# Usage
Run `cargo add libcdio-sys` to add the crate.

libcdio is split into multiple libraries: `libcdio`, `libiso9660` and
`libudf`. Likewise, libcdio-paranoia is split into `libcdio_cdda` and
`libcdio_paranoia`.

Cargo features are provided to control which libraries are included.

Run `cargo add libcdio-sys`, or add `libcdio-sys = "2"` to the `[dependencies]` section of your Cargo.toml.
## Versioning
The crate's version reflects three things:
For example: `v3.0.0+2.4.0p2.0.2`.
- `v3.0.0`: Crate version
- `+2.4.0`: libcdio's version
- `p2.0.2`: libcdio-paranoia's version (`10.2+2.0.2` in this case)
Everything beyond the `+` is ignored by Cargo during resolution.

libcdio is split into multiple libraries: `libcdio`, `libiso9660` and `libudf`. (Likewise, libcdio-paranoia is split into `libcdio_cdda` and `libcdio_paranoia`.) The `libcdio-sys` crate always links against `libcdio`, and can link against the others depending on which Cargo features are enabled.
## Vendoring
Enable the `vendored` feature to always perform vendored builds.

The available Cargo features are `iso9660`, `udf`, `cdda` and `paranoia`. The first two are enabled by default; the last two require libcdio-paranoia, which is usually installed separately from libcdio.
If disabled, the crate will attempt to use the libraries from the
system before falling back to vendoring if that fails.
To force a non-vendored build, set the `LIBCDIO_NO_VENDOR` environment
variable.

## Prerequisites
Non-vendored builds use the version metadata as a lower bound
when probing the system, allowing any newer non-major version.
Thus, a non-vendored build for `v3.0.0+2.4.0p2.0.2` would probe the
system for libcdio `>= 2.4.0, < 3.0.0` and (if features are enabled)
libcdio-paranoia `>= 10.2+2.0.2, < 10.2+3.0.0`.

You need to have libcdio and its headers installed in order to build this crate.
You need to have libcdio and its headers installed for non-vendored builds.

pkg-config is also required to build this crate normally, though this requirement can be avoided by setting the following environment variables:
pkg-config is also required for this, though this requirement can be
avoided by setting the following environment variables:

| Feature | Environment variables |
| ---------- | --------------------------------------------------------------------------------------------- |
Expand All @@ -30,10 +51,12 @@ pkg-config is also required to build this crate normally, though this requiremen
| `cdda` | `SYSTEM_DEPS_LIBCDIO_CDDA_NO_PKG_CONFIG=1 SYSTEM_DEPS_LIBCDIO_CDDA_LIB=cdio_cdda` |
| `paranoia` | `SYSTEM_DEPS_LIBCDIO_PARANOIA_NO_PKG_CONFIG=1 SYSTEM_DEPS_LIBCDIO_PARANOIA_LIB=cdio_paranoia` |

## Overriding the libcdio library

To control the libcdio library used when building this crate, set the `PKG_CONFIG_PATH` environment variable to the path of the directory containing pkg-config files for the correct library.
Alternatively, set the the following environment variables, depending on which features you have enabled:
### Overriding the system library
To control the shared library used in a non-vendored build, set the
`PKG_CONFIG_PATH` environment variable to the path of the directory
containing pkg-config files for the correct library.
Alternatively, set the the following environment variables, depending
on which features you have enabled:

| Feature | Library path | Include path |
| ---------- | -------------------------------------------- | -------------------------------------- |
Expand All @@ -47,7 +70,6 @@ Variables in the "Library path" column should be set to the path of the director
See the [system-deps documentation](https://docs.rs/system-deps/7/system_deps/) for more information.

# License

Copyright © 2018, 2019, 2020, 2023, 2025 Joaquim Monteiro

This program is free software: you can redistribute it and/or modify
Expand Down
Loading