Skip to content

Build with NDK 28 or newer for 16KB page alignment #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
Expand All @@ -36,3 +36,10 @@ jobs:
cd android
./gradlew build
ls -lh build/outputs/aar

- name: Upload Android library
uses: actions/upload-artifact@v4
with:
name: android-library
path: |
android/build/outputs/aar/
41 changes: 41 additions & 0 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import org.gradle.tooling.BuildException
import java.util.Base64
import java.util.Properties
import kotlin.io.path.Path
import kotlin.io.path.absolutePathString
import kotlin.io.path.exists
import kotlin.io.path.listDirectoryEntries
import kotlin.io.path.name

plugins {
id("maven-publish")
Expand All @@ -14,7 +21,41 @@ repositories {
google()
}

fun ndkPath(): String {
val file = project.rootProject.file("local.properties")
var androidHome = System.getenv("ANDROID_HOME")

if (file.exists()) {
val properties = Properties()
properties.load(project.rootProject.file("local.properties").inputStream())

properties["sdk.dir"]?.let {
androidHome = it as String
}
}

check(androidHome != null) { "Could not find android SDK dir" }

val ndks = Path(androidHome).resolve("ndk")
check(ndks.exists()) { "Expected NDK installations at $ndks" }

for (entry in ndks.listDirectoryEntries()) {
val name = entry.name
val majorVersion = name.split('.').first().toInt()

// We want to use NDK 28 or newer to build with 16KB support by default.
if (majorVersion >= 28) {
return entry.absolutePathString()
}
}

error("Expected an NDK 28 or later installation in $ndks")
}

val buildRust = tasks.register<Exec>("buildRust") {
group = "build"
environment("ANDROID_NDK_HOME", ndkPath())

workingDir("..")
commandLine(
"cargo",
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down