ndk-build: Link and zipalign all libraries to 16KiB
#175
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: [push, pull_request] | |
| jobs: | |
| formatting: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Format | |
| run: cargo fmt --all -- --check | |
| clippy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Clippy | |
| run: cargo clippy --workspace --all-targets --all-features --exclude ndk-examples -- -Dwarnings | |
| rust-msrv: | |
| name: Build-test MSRV (1.70) with minimal crate dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@nightly | |
| - name: Generate minimal-version dependencies | |
| run: cargo -Zminimal-versions generate-lockfile | |
| - uses: dtolnay/[email protected] | |
| - name: Cargo check | |
| run: cargo check --workspace --all-targets --all-features --exclude ndk-examples | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| rust-channel: [stable, nightly] | |
| rust-target: | |
| - armv7-linux-androideabi | |
| - aarch64-linux-android | |
| - i686-linux-android | |
| - x86_64-linux-android | |
| include: | |
| - os: windows-latest | |
| rust-channel: stable | |
| rust-target: aarch64-linux-android | |
| - os: windows-latest | |
| rust-channel: stable | |
| rust-target: x86_64-linux-android | |
| - os: macos-latest | |
| rust-channel: stable | |
| rust-target: x86_64-linux-android | |
| runs-on: ${{ matrix.os }} | |
| name: Build apk | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Installing Rust ${{ matrix.rust-channel }} w/ ${{ matrix.rust-target }} | |
| run: | | |
| rustup toolchain install ${{ matrix.rust-channel }} | |
| rustup default ${{ matrix.rust-channel }} | |
| rustup target add ${{ matrix.rust-target }} | |
| - name: Install cargo-apk | |
| run: cargo install --path cargo-apk | |
| - name: Cargo apk build for target ${{ matrix.rust-target }} | |
| run: cargo apk build -p ndk-examples --target ${{ matrix.rust-target }} --examples | |
| - uses: actions/upload-artifact@v4 | |
| # Only need this for CI, unless users are interested in downloading | |
| # a ready-made app that does nothing but printing "hello world". | |
| if: ${{ matrix.rust-target == 'x86_64-linux-android' && matrix.rust-channel == 'stable' }} | |
| name: Upload hello_world apk | |
| with: | |
| name: hello_world_${{ matrix.os }}_${{ matrix.rust-target }}_${{ matrix.rust-channel }} | |
| path: ./target/debug/apk/examples/hello_world.apk | |
| android_emulator: | |
| name: hello_world example on emulator | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| source_os: [local, windows-latest, macos-latest] | |
| env: | |
| api-level: 29 | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| arch: x86_64 | |
| # the `googleapis` emulator target is considerably slower on CI. | |
| target: default | |
| profile: Nexus 6 | |
| steps: | |
| # https://github.com/reactivecircus/android-emulator-runner?tab=readme-ov-file#running-hardware-accelerated-emulators-on-linux-runners | |
| - name: Enable KVM group perms | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| name: Download hello_world APK | |
| if: ${{ matrix.source_os != 'local' }} | |
| id: download | |
| with: | |
| name: hello_world_${{ matrix.source_os }}_x86_64-linux-android_stable | |
| - name: Install `cargo-apk` and add `x86_64-linux-android` target | |
| if: ${{ matrix.source_os == 'local' }} | |
| run: | | |
| cargo install --path cargo-apk | |
| rustup target add x86_64-linux-android | |
| - name: AVD cache | |
| uses: actions/cache@v3 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-${{ env.api-level }} | |
| - name: create AVD and generate snapshot for caching | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ env.api-level }} | |
| arch: ${{ env.arch }} | |
| target: ${{ env.target }} | |
| profile: ${{ env.profile }} | |
| emulator-options: ${{ env.emulator-options }} | |
| disable-animations: true | |
| force-avd-creation: false | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: Start hello_world example | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ env.api-level }} | |
| arch: ${{ env.arch }} | |
| target: ${{ env.target }} | |
| profile: ${{ env.profile }} | |
| emulator-options: -no-snapshot-save ${{ env.emulator-options }} | |
| disable-animations: true | |
| force-avd-creation: false | |
| script: ./.github/workflows/android_test.sh "${{ steps.download.outputs.download-path }}" | |
| - name: Upload emulator logs | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ always() }} | |
| with: | |
| name: app-logs-${{ matrix.source_os }} | |
| path: ~/logcat.log | |
| build-host: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| rust-channel: [stable, nightly] | |
| runs-on: ${{ matrix.os }} | |
| name: Host-side tests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Installing Rust ${{ matrix.rust-channel }} | |
| run: | | |
| rustup toolchain install ${{ matrix.rust-channel }} | |
| rustup default ${{ matrix.rust-channel }} | |
| - name: Test ndk-build | |
| run: cargo test -p ndk-build --all-features | |
| - name: Test cargo-apk | |
| run: cargo test -p cargo-apk --all-features | |
| docs: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| rust-channel: [stable, nightly] | |
| runs-on: ${{ matrix.os }} | |
| name: Build-test docs | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Installing Rust ${{ matrix.rust-channel }} | |
| run: | | |
| rustup toolchain install ${{ matrix.rust-channel }} | |
| rustup default ${{ matrix.rust-channel }} | |
| - name: Document all crates | |
| env: | |
| RUSTDOCFLAGS: -Dwarnings | |
| run: cargo doc --all --all-features |