diff --git a/.github/actions/android-ndk/action.yml b/.github/actions/android-ndk/action.yml new file mode 100644 index 000000000000..eb9ab9bfe0ee --- /dev/null +++ b/.github/actions/android-ndk/action.yml @@ -0,0 +1,25 @@ +name: 'Install Android NDK' +description: 'Install the android NDK' + +inputs: + target: + description: 'Rust target being used' + required: true + android-platform: + description: 'Platform version to use for the C compiler' + required: false + default: '26' + +runs: + using: composite + steps: + - run: | + rust=${{ inputs.target }} + upcase=$(echo $rust | awk '{ print toupper($0) }' | sed 's/-/_/g') + ndk_bin=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin + linker=$ndk_bin/${rust}${{ inputs.android-platform }}-clang + echo CARGO_TARGET_${upcase}_LINKER=$linker >> $GITHUB_ENV + echo CC_${rust}=$linker >> $GITHUB_ENV + echo RANLIB_${rust}=$ndk_bin/llvm-ranlib >> $GITHUB_ENV + echo AR_${rust}=$ndk_bin/llvm-ar >> $GITHUB_ENV + shell: bash diff --git a/.github/actions/binary-compatible-builds/main.js b/.github/actions/binary-compatible-builds/main.js index 6230126fcb81..0e4d4d814cc9 100755 --- a/.github/actions/binary-compatible-builds/main.js +++ b/.github/actions/binary-compatible-builds/main.js @@ -21,6 +21,12 @@ if (process.platform == 'win32') { return; } +// Android doesn't use a container as it's controlled by the installation of the +// SDK/NDK. +if (processe.env.INPUT_NAME && process.env.INPUT_NAME.indexOf("android") >= 0) { + return; +} + // ... and on Linux we do fancy things with containers. We'll spawn an old // CentOS container in the background with a super old glibc, and then we'll run // commands in there with the `$CENTOS` env var. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3622d41cc767..f11696e12a3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,6 +25,7 @@ on: # tag at the end of CI if successful and the tag will trigger the artifact # uploads as well as publication to crates.io. - 'release-*' + - test-android-build defaults: run: @@ -306,8 +307,6 @@ jobs: needs: determine name: Check runs-on: ubuntu-latest - env: - CARGO_NDK_VERSION: 2.12.2 steps: - uses: actions/checkout@v4 with: @@ -389,23 +388,6 @@ jobs: - run: rustup target add x86_64-unknown-freebsd - run: cargo check -p wasmtime --no-default-features --features cranelift,wat,async,cache --target x86_64-unknown-freebsd - # Check whether `wasmtime` cross-compiles to aarch64-linux-android - - run: rustup target add aarch64-linux-android - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - name: Setup Android SDK - uses: android-actions/setup-android@v3 - - uses: actions/cache@v4 - with: - path: ${{ runner.tool_cache }}/cargo-ndk - key: cargo-ndk-bin-${{ env.CARGO_NDK_VERSION }} - - run: echo "${{ runner.tool_cache }}/cargo-ndk/bin" >> $GITHUB_PATH - - run: cargo install --root ${{ runner.tool_cache }}/cargo-ndk --version ${{ env.CARGO_NDK_VERSION }} cargo-ndk --locked - - run: cargo ndk -t arm64-v8a check -p wasmtime - # Run clippy configuration - run: rustup component add clippy - run: cargo clippy --workspace @@ -881,6 +863,11 @@ jobs: with: name: ${{ matrix.build }} + - uses: ./.github/actions/android-ndk + if: contains(matrix.target, 'android') + with: + target: ${{ matrix.target }} + - run: $CENTOS ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}" # Assemble release artifacts appropriate for this platform, then upload them diff --git a/ci/build-build-matrix.js b/ci/build-build-matrix.js index ae48a5f22966..842348c96978 100644 --- a/ci/build-build-matrix.js +++ b/ci/build-build-matrix.js @@ -49,6 +49,16 @@ const array = [ "os": "windows-latest", "target": "x86_64-pc-windows-gnu", }, + { + "build": "aarch64-android", + "os": "ubuntu-latest", + "target": "aarch64-linux-android", + }, + { + "build": "x86_64-android", + "os": "ubuntu-latest", + "target": "x86_64-linux-android", + }, ]; const builds = [];