From 10d45bdb476fa16f1eed2aa6b1f0ca12e0462e5a Mon Sep 17 00:00:00 2001 From: blackspherefollower Date: Thu, 3 Oct 2024 16:32:11 +0100 Subject: [PATCH] build: Add Android CI and fix jni/jni_utils version Android is currently broken in dev due to a change in the jni crate that's not supported by jni_utils. This was undetected due to lack of CI. --- .github/workflows/rust.yml | 46 ++++++++++++++++++++++++++++++++++---- Cargo.toml | 2 +- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 08621537..d0fd9d6c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,12 +14,30 @@ jobs: build: strategy: matrix: - os: - - macOS-latest - - ubuntu-latest - - windows-latest + target: + - macos + - linux + - windows + - android + include: + - target: macos + os: macOS-latest + cbt: aarch64-apple-darwin + - target: linux + os: ubuntu-latest + cbt: x86_64-unknown-linux-gnu + - target: windows + os: windows-latest + cbt: x86_64-pc-windows-msvc + - target: android + os: ubuntu-latest + cbt: aarch64-linux-android + runs-on: ${{ matrix.os }} + env: + CARGO_BUILD_TARGET: ${{ matrix.cbt }} + steps: - uses: actions/checkout@v2 - name: Install dependencies @@ -27,6 +45,26 @@ jobs: run: | sudo apt-get update sudo apt-get install libdbus-1-dev + - uses: actions/setup-java@v2 + if: ${{ matrix.target == 'android' }} + with: + distribution: 'zulu' + java-version: '17' + - name: Setup NDK + if: ${{ matrix.target == 'android' }} + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r25b + local-cache: true + - name: rust toolchain + if: ${{ matrix.target == 'android' }} + uses: actions-rs/toolchain@v1 + with: + profile: minimal + target: aarch64-linux-android + toolchain: stable + override: true - name: Check run: cargo check --all --bins --examples - name: Check without default features diff --git a/Cargo.toml b/Cargo.toml index 9e370a73..cfaeaf31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ dbus = "0.9.7" bluez-async = "0.7.2" [target.'cfg(target_os = "android")'.dependencies] -jni = "0.21.1" +jni = "0.19.0" once_cell = "1.19.0" jni-utils = "0.1.1"