Skip to content

Commit

Permalink
Try detecting the NDK version automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Nov 25, 2024
1 parent cbfcfcb commit 3799726
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ jobs:
matrix:
api-level: [29]
steps:
- name: Set env vars
run: |
echo "ANDROID_NDK_TOOLCHAIN_DIR=$ANDROID_NDK_HOME/toolchains" >> $GITHUB_ENV
export ANDROID_NDK_TOOLCHAIN_DIR=$ANDROID_NDK_HOME/toolchains
echo "Toolchain dir: $ANDROID_NDK_TOOLCHAIN_DIR."
echo "Contents:"
find $ANDROID_NDK_TOOLCHAIN_DIR -maxdepth 1
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -50,8 +58,6 @@ jobs:

- name: Setup Gradle & Build test cases
uses: gradle/gradle-build-action@v3
env:
ANDROID_NDK_TOOLCHAIN_DIR: ${{ env.ANDROID_NDK_HOME }}/toolchains
with:
build-root-directory: platforms/android
cache-read-only: false
Expand Down
12 changes: 10 additions & 2 deletions platforms/android/library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cargo {
targets = ["arm", "x86", "x86_64", "arm64"]
targetIncludes = ["libuniffi_wysiwyg_composer.so"]
targetDirectory = '../../../target'
prebuiltToolchains = true
}

android {
Expand Down Expand Up @@ -69,12 +70,12 @@ android {
jacocoVersion = "0.8.8"
}

ndkVersion = "27.1.12297006"

packagingOptions {
resources.excludes += 'META-INF/LICENSE.md'
resources.excludes += 'META-INF/LICENSE-notice.md'
}

ndkVersion getNdkVersionAsWorkaround()
}

kotlin {
Expand Down Expand Up @@ -143,3 +144,10 @@ tasks.withType(Test) {
jacoco.excludes = ['jdk.internal.*']
}

// Workaround for https://github.com/mozilla/rust-android-gradle/issues/46
// This looks for the NDK path like: '/some/path/to/sdk/ndk/23.0.7599858'
// and takes the last path component, which should be the version number
def getNdkVersionAsWorkaround() {
def ndkDirectory = new File(android.sdkDirectory, "ndk")
return ndkDirectory.list().sort().last().split(PATH_SEPARATOR).last()
}

0 comments on commit 3799726

Please sign in to comment.