From ee00d39c79986cfd5d9c7d8c5698208ac7dd1aed Mon Sep 17 00:00:00 2001 From: Daohan Chong Date: Tue, 22 Mar 2022 09:54:24 +0800 Subject: [PATCH] Fix Android Actions (#3) * Add android * Update android pipeline * Update JDK * set up toolchain * Update abi * More deps * Add more target --- .github/workflows/build.yml | 53 ++++++++++++++++++++++--------------- Makefile | 14 +++++++++- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 23b964b..82ae034 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,24 +25,35 @@ jobs: path: hello/target/HelloFFI.xcframework retention-days: 7 - # build_android: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # with: - # lfs: true - # - uses: actions/setup-java@v2 - # with: - # distribution: 'microsoft' - # java-version: '11' - # - name: Setup Android SDK - # uses: android-actions/setup-android@v2 - # - uses: nttld/setup-ndk@v1 - # with: - # ndk-version: r21e - # - name: "Build Android library" - # env: - # ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - # run: | - # cd hello/platforms/android/UniffiRustExample - # ./gradlew cargoBuild --info + build_android: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + lfs: true + - uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 11 + cache: 'gradle' + # Reference: https://github.com/mozilla/rust-android-gradle/blob/master/.github/workflows/check.yml + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + - uses: nttld/setup-ndk@v1 + with: + ndk-version: r21e + - uses: actions-rs/toolchain@v1 + # Reference: https://github.com/rust-windowing/android-ndk-rs/blob/master/.github/workflows/rust.yml + with: + toolchain: stable + override: true + target: aarch64-linux-android + - name: "More dependencies" + run: | + make prepare-android + - name: "Build Android library" + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} + run: | + cd hello/platforms/android/UniffiRustExample + ./gradlew cargoBuild --info diff --git a/Makefile b/Makefile index 372d5c0..9238113 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,16 @@ prepare-apple: rustup toolchain install nightly rustup target add aarch64-apple-ios-sim --toolchain nightly && rustup target add aarch64-apple-ios x86_64-apple-ios rustup component add rust-src --toolchain nightly - cargo install uniffi_bindgen + make install-uniffi-bindgen + +prepare-android: + rustup toolchain install stable + rustup target add x86_64-linux-android + rustup target add x86_64-unknown-linux-gnu + rustup target add aarch64-linux-android + rustup target add armv7-linux-androideabi + rustup target add i686-linux-android + make install-uniffi-bindgen + +install-uniffi-bindgen: + cargo install uniffi_bindgen --version 0.17.0 \ No newline at end of file