Add Android native artifacts and CI coverage#148
Closed
subham8907 wants to merge 1 commit into
Closed
Conversation
subham8907
force-pushed
the
codex/android-native-ci-squashed
branch
from
May 9, 2026 12:24
3f0535e to
d90ba5c
Compare
Contributor
Author
|
Recreated from renamed branch: #149 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds checked-in Android native artifacts for the core
tree-sitterlibrary and the grammar packages used by downstream Android consumers, while keeping the existing desktop/native artifacts current for those refreshed modules.It also adjusts the Gradle build so regular tests consume the checked-in native libraries instead of rebuilding native code, while CI explicitly compiles native artifacts for every grammar project.
What changed
aarch64-linux-androidshared libraries for:tree-sittertree-sitter-csstree-sitter-gotree-sitter-htmltree-sitter-javatree-sitter-javascripttree-sitter-jsontree-sitter-pythontree-sitter-typescriptNativeUtils:System.loadLibrary(...)on Android instead of extracting and loading the resource path manually.JNI_OnLoadfromJNI_VERSION_10toJNI_VERSION_1_6so the native library can load on Android runtimes that do not accept the newer JNI version.~/Library/Android/sdkwhen Android SDK environment variables are not set.ANDROID_NDK_HOME,ANDROID_NDK_ROOT,ANDROID_HOME, andANDROID_SDK_ROOT.tree-sitter-ocaml:buildNativeby pointing it at the OCaml grammar source layout undergrammars/ocaml/src.build.gradle:downloadSourceandbuildNativeonly for projects that definelibVersion.processResources/tests tobuildNative, so./gradlew testdoes not unexpectedly rebuild native artifacts../gradlew buildNativeso every grammar project's native task is compiled for each configured desktop target../gradlew buildNative -PtreeSitterTargets=aarch64-linux-androidin the Android job so Android native compilation also covers all grammar projects.Why
Android consumers need packaged native grammar libraries, but the desktop JVM loading path is not appropriate for Android. Android expects libraries to be loaded through the platform linker with
System.loadLibrary, and the JNI version returned byJNI_OnLoadmust be compatible with Android.The test/build wiring also needed to avoid rebuilding native libraries during normal test runs. Native compilation is now exercised deliberately by CI through
buildNative, while./gradlew testremains focused on tests and uses the checked-in resources.Validation
./gradlew :tree-sitter-ocaml:buildNative -PtreeSitterTargets=aarch64-macos --stacktrace./gradlew buildNative -PtreeSitterTargets=aarch64-macos --stacktrace./gradlew :tree-sitter-ocaml:test --stacktrace./gradlew test --stacktrace