From 7e4e27acde239d5bfa4f8e0eb97122eaecfacf4a Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Tue, 12 Aug 2025 14:20:05 -0400 Subject: [PATCH 1/9] create Dockerfile --- Dockerfile.arm64 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Dockerfile.arm64 diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 000000000..78909ba6d --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,13 @@ +FROM rust:latest + +# Install required dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libasound2-dev \ + libjack-jackd2-dev \ + libjack-jackd2-0 \ + pkg-config \ + +# Set /cpal/ to working directory +WORKDIR /cpal +COPY . . \ No newline at end of file From a5dde9a4f5454194fab00cb3cffd8b8565bddb44 Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Tue, 12 Aug 2025 14:20:24 -0400 Subject: [PATCH 2/9] include dbus-1 support --- Dockerfile.arm64 | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 78909ba6d..0b1c3ba40 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -7,6 +7,7 @@ RUN apt-get update && \ libjack-jackd2-dev \ libjack-jackd2-0 \ pkg-config \ + libdbus-1-dev \ # Set /cpal/ to working directory WORKDIR /cpal From f541c602179032403444931f3a51bfb09d057751 Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Tue, 12 Aug 2025 19:25:19 -0400 Subject: [PATCH 3/9] finish creating dockerfile --- Dockerfile | 4 ++-- Dockerfile.arm64 | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3fa3b24ab..8e56a2efd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ ARG CROSS_BASE_IMAGE FROM $CROSS_BASE_IMAGE -ENV PKG_CONFIG_ALLOW_CROSS 1 -ENV PKG_CONFIG_PATH /usr/lib/arm-linux-gnueabihf/pkgconfig/ +ENV PKG_CONFIG_ALLOW_CROSS=1 +ENV PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/ RUN dpkg --add-architecture armhf && \ apt-get update && \ diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 0b1c3ba40..641985b7c 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -11,4 +11,7 @@ RUN apt-get update && \ # Set /cpal/ to working directory WORKDIR /cpal -COPY . . \ No newline at end of file +COPY . . + +# When running this Docker container, ensure ALSA devices are exposed +# using `--device /dev/snd` and `--group-add audio` \ No newline at end of file From 4a99f1f4177f91bb52a624b627bc51de13395aed Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Tue, 12 Aug 2025 19:33:24 -0400 Subject: [PATCH 4/9] minor fix --- Dockerfile.arm64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 641985b7c..62b886fbd 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -7,7 +7,7 @@ RUN apt-get update && \ libjack-jackd2-dev \ libjack-jackd2-0 \ pkg-config \ - libdbus-1-dev \ + libdbus-1-dev # Set /cpal/ to working directory WORKDIR /cpal From 7e5dafa58625885f2c4038b40da43a94966ca51d Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Tue, 12 Aug 2025 19:46:58 -0400 Subject: [PATCH 5/9] added runner to test arm64 linux --- .github/workflows/cpal.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/cpal.yml b/.github/workflows/cpal.yml index 765e6f09d..5091a23b5 100644 --- a/.github/workflows/cpal.yml +++ b/.github/workflows/cpal.yml @@ -104,6 +104,18 @@ jobs: - name: Test all features for armv7 run: cross test --target armv7-unknown-linux-gnueabihf --workspace --all-features --verbose + linux-check-and-test-arm64: + runs-on: ubuntu-22.04-arm64 + steps: + - name: Build Docker container for arm64 + run: docker build -f Dockerfile.arm64 -t cpal-arm64 . + + - name: Run without features + run: docker run --rm cpal-arm64 cargo test --all --no-default-features --verbose + + - name: Run all features + run: docker run --rm cpal-arm64 cargo test --all --all-features --verbose + asmjs-wasm32-test: strategy: matrix: From 0ddae6a74cb9ece062afbe44e00e6a830434c61a Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Thu, 14 Aug 2025 18:10:31 -0400 Subject: [PATCH 6/9] attempt to fix workflow file --- .github/workflows/cpal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpal.yml b/.github/workflows/cpal.yml index 5091a23b5..58720fffb 100644 --- a/.github/workflows/cpal.yml +++ b/.github/workflows/cpal.yml @@ -105,7 +105,7 @@ jobs: run: cross test --target armv7-unknown-linux-gnueabihf --workspace --all-features --verbose linux-check-and-test-arm64: - runs-on: ubuntu-22.04-arm64 + runs-on: ubuntu-24.04-arm steps: - name: Build Docker container for arm64 run: docker build -f Dockerfile.arm64 -t cpal-arm64 . From 80c3b368b16af72ddeb089e84d6dcfa1f754abee Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Thu, 14 Aug 2025 18:16:08 -0400 Subject: [PATCH 7/9] debug --- .github/workflows/cpal.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cpal.yml b/.github/workflows/cpal.yml index 58720fffb..7e9f4734b 100644 --- a/.github/workflows/cpal.yml +++ b/.github/workflows/cpal.yml @@ -107,6 +107,12 @@ jobs: linux-check-and-test-arm64: runs-on: ubuntu-24.04-arm steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Debug testing... + run: ls -la + - name: Build Docker container for arm64 run: docker build -f Dockerfile.arm64 -t cpal-arm64 . From c4c5662c5f0ff9efd5da851d68c990f371b10fb7 Mon Sep 17 00:00:00 2001 From: DischordDynne Date: Thu, 14 Aug 2025 18:17:39 -0400 Subject: [PATCH 8/9] remove debug --- .github/workflows/cpal.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/cpal.yml b/.github/workflows/cpal.yml index 7e9f4734b..b5c2de1be 100644 --- a/.github/workflows/cpal.yml +++ b/.github/workflows/cpal.yml @@ -110,9 +110,6 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Debug testing... - run: ls -la - - name: Build Docker container for arm64 run: docker build -f Dockerfile.arm64 -t cpal-arm64 . From 52c9ac5c6c578df39e4abc6a08136aed4b8ef13a Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Wed, 24 Sep 2025 23:38:20 +0200 Subject: [PATCH 9/9] ci: Refactor workflows for unified cross-platform testing - Merge and restructure jobs for Linux, Windows, macOS, Android, iOS, and WASM - Add native ARM64 Linux support in GitHub Actions - Remove Dockerfile.arm64 and Docker-based ARM64 testing - Consolidate clippy and rustfmt checks - Improve dependency installation and matrix strategy --- .github/workflows/cpal.yml | 388 +++++++++++++++++-------------------- CHANGELOG.md | 1 + Dockerfile.arm64 | 17 -- 3 files changed, 179 insertions(+), 227 deletions(-) delete mode 100644 Dockerfile.arm64 diff --git a/.github/workflows/cpal.yml b/.github/workflows/cpal.yml index b5c2de1be..5c02fbe02 100644 --- a/.github/workflows/cpal.yml +++ b/.github/workflows/cpal.yml @@ -4,50 +4,37 @@ on: [push, pull_request] jobs: - clippy-test: + clippy-and-fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Update apt - run: sudo apt update - - name: Install alsa - run: sudo apt-get install libasound2-dev - - name: Install libjack - run: sudo apt-get install libjack-jackd2-dev libjack-jackd2-0 - - name: Install dbus - run: sudo apt-get install libdbus-1-dev - - name: Install stable + - name: Install Linux audio dependencies + run: | + sudo apt update + sudo apt-get install -y libasound2-dev libjack-jackd2-dev libjack-jackd2-0 libdbus-1-dev + - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: - components: clippy - target: armv7-linux-androideabi + components: clippy, rustfmt + targets: armv7-linux-androideabi + - name: Run rustfmt + run: cargo fmt --all -- --check - name: Run clippy run: cargo clippy --all --all-features - name: Run clippy for Android target run: cargo clippy --all --features asio --target armv7-linux-androideabi - rustfmt-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install stable - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - name: Run rustfmt - run: cargo fmt --all -- --check - cargo-publish: if: github.event_name == 'push' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install rust + - name: Install Linux audio dependencies + run: | + sudo apt update + sudo apt-get install -y libasound2-dev + - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - - name: Update apt - run: sudo apt update - - name: Install alsa - run: sudo apt-get install libasound2-dev - name: Verify publish crate uses: katyo/publish-crates@v2 with: @@ -59,225 +46,206 @@ jobs: ignore-unpublished-changes: true registry-token: ${{ secrets.CRATESIO_TOKEN }} - ubuntu-test: - runs-on: ubuntu-latest + # Native platform testing + test-native: + strategy: + fail-fast: false + matrix: + include: + # Linux x86_64 + - os: ubuntu-latest + name: linux-x64 + deps: | + sudo apt update + sudo apt-get install -y libasound2-dev libjack-jackd2-dev libjack-jackd2-0 libdbus-1-dev + + # Linux ARM64 native + - os: ubuntu-24.04-arm + name: linux-arm64 + deps: | + sudo apt update + sudo apt-get install -y libasound2-dev libjack-jackd2-dev libjack-jackd2-0 libdbus-1-dev + + # Windows x86_64 + - os: windows-latest + name: windows-x64 + target: x86_64-pc-windows-msvc + deps: | + curl -L -o asio.zip https://www.steinberg.net/asiosdk + 7z x -oasio asio.zip + move asio\*\* asio\ + choco install asio4all + choco install llvm + asio-env: true + + # Windows i686 + - os: windows-latest + name: windows-x86 + target: i686-pc-windows-msvc + deps: | + curl -L -o asio.zip https://www.steinberg.net/asiosdk + 7z x -oasio asio.zip + move asio\*\* asio\ + choco install asio4all + choco install llvm + asio-env: true + + # macOS (ARM64 M1/M2) + - os: macOS-latest + name: macos-arm64 + deps: brew install llvm + build-beep: true + + runs-on: ${{ matrix.os }} + name: test-${{ matrix.name }} steps: - - uses: actions/checkout@v4 - - name: Update apt - run: sudo apt update - - name: Install alsa - run: sudo apt-get install libasound2-dev - - name: Install libjack - run: sudo apt-get install libjack-jackd2-dev libjack-jackd2-0 - - name: Install dbus - run: sudo apt-get install libdbus-1-dev - - name: Install stable - uses: dtolnay/rust-toolchain@stable - - name: Run without features - run: cargo test --all --no-default-features --verbose - - name: Run all features - run: cargo test --all --all-features --verbose + - uses: actions/checkout@v4 - linux-check-and-test-armv7: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 + - name: Install dependencies + run: ${{ matrix.deps }} - - name: Install stable toolchain + - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: - target: armv7-unknown-linux-gnueabihf - - - name: Install cross - run: cargo install cross + target: ${{ matrix.target }} - - name: Check without features for armv7 - run: cross check --target armv7-unknown-linux-gnueabihf --workspace --no-default-features --verbose + - name: Build beep example (macOS only) + if: matrix.build-beep + run: cargo build --example beep - - name: Test without features for armv7 - run: cross test --target armv7-unknown-linux-gnueabihf --workspace --no-default-features --verbose + - name: Run tests without features + run: cargo test --all --no-default-features --verbose - - name: Check all features for armv7 - run: cross check --target armv7-unknown-linux-gnueabihf --workspace --all-features --verbose + - name: Run tests with all features + shell: bash + run: | + if [[ "${{ matrix.asio-env }}" == "true" ]]; then + export CPAL_ASIO_DIR="$GITHUB_WORKSPACE/asio" + fi + cargo test --all --all-features --verbose - - name: Test all features for armv7 - run: cross test --target armv7-unknown-linux-gnueabihf --workspace --all-features --verbose + # Cross-compilation for architectures without native runners + test-cross: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [armv7-unknown-linux-gnueabihf] - linux-check-and-test-arm64: - runs-on: ubuntu-24.04-arm + name: test-cross-${{ matrix.target }} steps: - - name: Checkout sources - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Build Docker container for arm64 - run: docker build -f Dockerfile.arm64 -t cpal-arm64 . - - - name: Run without features - run: docker run --rm cpal-arm64 cargo test --all --no-default-features --verbose + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + target: ${{ matrix.target }} - - name: Run all features - run: docker run --rm cpal-arm64 cargo test --all --all-features --verbose + - name: Install cross + run: cargo install cross - asmjs-wasm32-test: - strategy: - matrix: - target: [wasm32-unknown-emscripten] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup Emscripten toolchain - uses: mymindstorm/setup-emsdk@v14 - - name: Install stable - uses: dtolnay/rust-toolchain@stable - with: - target: ${{ matrix.target }} - - name: Build beep example - run: cargo build --example beep --release --target ${{ matrix.target }} + - name: Check without features + run: cross check --target ${{ matrix.target }} --workspace --no-default-features --verbose - wasm32-bindgen-test: + - name: Test without features + run: cross test --target ${{ matrix.target }} --workspace --no-default-features --verbose - strategy: - matrix: - target: [wasm32-unknown-unknown] + - name: Check all features + run: cross check --target ${{ matrix.target }} --workspace --all-features --verbose - runs-on: ubuntu-latest + - name: Test all features + run: cross test --target ${{ matrix.target }} --workspace --all-features --verbose + # WebAssembly builds + test-wasm: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - target: wasm32-unknown-emscripten + setup-emscripten: true + args: --release + - target: wasm32-unknown-unknown + setup-emscripten: false + args: --features=wasm-bindgen + build-wasm-beep: true + - target: wasm32-wasip1 + setup-emscripten: false + args: "" + + name: test-wasm-${{ matrix.target }} steps: - uses: actions/checkout@v4 - - name: Install stable + + - name: Setup Emscripten toolchain + if: matrix.setup-emscripten + uses: mymindstorm/setup-emsdk@v14 + + - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: target: ${{ matrix.target }} + - name: Build beep example - run: cargo build --example beep --target ${{ matrix.target }} --features=wasm-bindgen + run: cargo build --example beep --target ${{ matrix.target }} ${{ matrix.args }} - wasm32-wasi-test: + - name: Build wasm-beep example + if: matrix.build-wasm-beep + working-directory: ./examples/wasm-beep + run: cargo build --target ${{ matrix.target }} - strategy: - matrix: - target: [wasm32-wasip1] + # Android cross-compilation + test-android: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - - name: Install stable + + - name: Install Rust toolchain (Android targets) uses: dtolnay/rust-toolchain@stable with: - target: ${{ matrix.target }} - - name: Build beep example - run: cargo build --example beep --target ${{ matrix.target }} + targets: armv7-linux-androideabi,aarch64-linux-android,i686-linux-android,x86_64-linux-android - windows-test: - strategy: - matrix: - version: [x86_64, i686] - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - name: Install ASIO SDK - env: - LINK: https://www.steinberg.net/asiosdk - run: | - curl -L -o asio.zip $env:LINK - 7z x -oasio asio.zip - move asio\*\* asio\ - - name: Install ASIO4ALL - run: choco install asio4all - - name: Install llvm and clang - run: choco install llvm - - name: Install stable - uses: dtolnay/rust-toolchain@stable - with: - target: ${{ matrix.version }}-pc-windows-msvc - - name: Run without features - run: cargo test --all --no-default-features --verbose - - name: Run all features - run: | - $Env:CPAL_ASIO_DIR = "$Env:GITHUB_WORKSPACE\asio" - cargo test --all --all-features --verbose + - name: Check Android examples + run: | + cargo check --example beep --target armv7-linux-androideabi --verbose + cargo check --example enumerate --target armv7-linux-androideabi --verbose + cargo check --example feedback --target armv7-linux-androideabi --verbose + cargo check --example record_wav --target armv7-linux-androideabi --verbose - macos-test: - runs-on: macOS-latest - steps: - - uses: actions/checkout@v4 - - name: Install llvm and clang - run: brew install llvm - - name: Install stable - uses: dtolnay/rust-toolchain@stable - - name: Build beep example - run: cargo build --example beep - - name: Run without features - run: cargo test --all --no-default-features --verbose - - name: Run all features - run: cargo test --all --all-features --verbose - - android-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install stable (Android target) - uses: dtolnay/rust-toolchain@stable - with: - target: armv7-linux-androideabi - - name: Check android - working-directory: examples/android - run: cargo check --target armv7-linux-androideabi --verbose - - name: Check beep - run: cargo check --example beep --target armv7-linux-androideabi --verbose - - name: Check enumerate - run: cargo check --example enumerate --target armv7-linux-androideabi --verbose - - name: Check feedback - run: cargo check --example feedback --target armv7-linux-androideabi --verbose - - name: Check record_wav - run: cargo check --example record_wav --target armv7-linux-androideabi --verbose - - android-apk-build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install stable (Android targets) - uses: dtolnay/rust-toolchain@stable - with: - targets: armv7-linux-androideabi,aarch64-linux-android,i686-linux-android,x86_64-linux-android - - name: Set Up Android tools - run: | - ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;30.0.2" "platforms;android-30" - - name: Install Cargo APK - run: cargo install cargo-apk - - name: Build APK - working-directory: examples/android - run: cargo apk build - - ios-build: + - name: Check Android project + working-directory: examples/android + run: cargo check --target armv7-linux-androideabi --verbose + + - name: Set up Android SDK + run: | + ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;30.0.2" "platforms;android-30" + + - name: Install Cargo APK + run: cargo install cargo-apk + + - name: Build APK + working-directory: examples/android + run: cargo apk build + + # iOS cross-compilation + test-ios: runs-on: macOS-latest - steps: - - uses: actions/checkout@v4 - - name: Install llvm and clang - run: brew install llvm - - name: Install stable (iOS targets) - uses: dtolnay/rust-toolchain@stable - with: - targets: aarch64-apple-ios,x86_64-apple-ios - - name: Install cargo lipo - run: cargo install cargo-lipo - - name: Build iphonesimulator feedback example - run: cd examples/ios-feedback && xcodebuild -scheme cpal-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator - - wasm-beep-build: - # this only confirms that the Rust source builds - # and checks to prevent regressions like #721. - # - # It does not test the javascript/web integration - runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install stable (wasm32 target) + + - name: Install dependencies + run: brew install llvm + + - name: Install Rust toolchain (iOS targets) uses: dtolnay/rust-toolchain@stable with: - targets: wasm32-unknown-unknown - - name: Cargo Build - working-directory: ./examples/wasm-beep - run: cargo build --target wasm32-unknown-unknown + targets: aarch64-apple-ios,x86_64-apple-ios + + - name: Install cargo lipo + run: cargo install cargo-lipo + + - name: Build iOS example + run: cd examples/ios-feedback && xcodebuild -scheme cpal-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fe4cb9bd..5d2d0fe8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - ALSA: Add `I24` and `U24` sample format support (24-bit samples stored in 4 bytes). - ALSA(process_output): Pass `silent=true` to `PCM.try_recover`, so it doesn't write to stderr. - ASIO: Fix linker flags for MinGW cross-compilation. +- CI: Added native ARM64 Linux support in GitHub Actions. - CoreAudio: Change `Device::supported_configs` to return a single element containing the available sample rate range when all elements have the same `mMinimum` and `mMaximum` values. - CoreAudio: Change default audio device detection to be lazy when building a stream, instead of during device enumeration. - CoreAudio: Add `i8`, `i32` and `I24` sample format support (24-bit samples stored in 4 bytes). diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 deleted file mode 100644 index 62b886fbd..000000000 --- a/Dockerfile.arm64 +++ /dev/null @@ -1,17 +0,0 @@ -FROM rust:latest - -# Install required dependencies -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - libasound2-dev \ - libjack-jackd2-dev \ - libjack-jackd2-0 \ - pkg-config \ - libdbus-1-dev - -# Set /cpal/ to working directory -WORKDIR /cpal -COPY . . - -# When running this Docker container, ensure ALSA devices are exposed -# using `--device /dev/snd` and `--group-add audio` \ No newline at end of file