Skip to content

Commit

Permalink
test android build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed May 12, 2024
1 parent e6f9ca5 commit 1cf7747
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
25 changes: 25 additions & 0 deletions .github/actions/android-ndk/action.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .github/actions/binary-compatible-builds/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 6 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions ci/build-build-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down

0 comments on commit 1cf7747

Please sign in to comment.