Skip to content

Commit

Permalink
Make rust core use NDK >= r23 (#1086)
Browse files Browse the repository at this point in the history
* Build Rust with newer NDK version

* Update README

* Add more explanation

* Put libgcc in a dedicated folder

* Add proper fix

* Try Android NDK Home

* Update cargo ndk to handle lgcc linkage

* Point to correct NDK path

* Use ANDROID_NDK_HOME instead

* Try re-exporting

* Fix the rest of workflows

* Update docs

* Update README.md
  • Loading branch information
Ghenadie Vasiliev-Pusca authored Jul 28, 2022
1 parent 765f238 commit 4e565b8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
- if: matrix.language == 'java'
name: Build Android
run: |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME
./build.js
cd platform/android
make -C ../core android_bindings
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/daily-instrumentation-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
run: ./build.js build
- name: Build core
working-directory: platform/core
run: make
run: |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME
make android_bindings
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: ./build.js
- name: Build core
working-directory: platform/core
run: make
run: make ios_bindings
- name: Build and test iOS
working-directory: platform/ios
run: make test
4 changes: 3 additions & 1 deletion .github/workflows/js-and-android-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ jobs:
- name: Build core with Android bindings
if: steps.changes.outputs.android == 'true'
working-directory: platform/core
run: make android_bindings
run: |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME
make android_bindings
- name: Test android
if: steps.changes.outputs.android == 'true'
working-directory: platform/android
Expand Down
19 changes: 4 additions & 15 deletions platform/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ ios_targets := iPhone simulator
tools_dir := tools
android_core := PolyPodCoreAndroid/core/src/main/
android_version := 24
# Rust still uses old-ish r22 version of NDK.
# For reference https://github.com/rust-lang/rust/pull/85806
ndk_version := r22b
google_repo := https://dl.google.com/android/repository
ndk_lib := android-ndk-$(ndk_version)
ndk=$(tools_dir)/NDK_$(ndk_version)
ndk_archive = $(tools_dir)/NDK.zip
export ANDROID_NDK_HOME := $(ndk)/$(ndk_lib)
android_triples := aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
android_binaries := $(patsubst %, target/%, $(android_triples))
android_architectures := arm64-v8a armeabi-v7a x86_64 x86
jni_libs_copy_path := $(android_core)/jniLibs
android_core_libraries := $(patsubst %, $(jni_libs_copy_path)/%, $(android_architectures))
cargo_ndk_version = 2.10.0

ifeq ($(OS),Windows_NT)
ndk_download_url = $(google_repo)/$(ndk_lib)-windows-x86_64.zip
Expand All @@ -45,6 +39,7 @@ else
endif



# ============ Rust core ============ #

$(target):
Expand Down Expand Up @@ -100,14 +95,8 @@ endef

# ============ Android lib ============ #

$(ndk):
mkdir -p $(ndk)
curl -L $(ndk_download_url) -o $(ndk_archive)
unzip -q -d $(ndk) $(ndk_archive)
rm $(ndk_archive)

$(android_binaries): $(target) $(ndk)
cargo install cargo-ndk
$(android_binaries): $(target)
cargo install cargo-ndk --version $(cargo_ndk_version)
rustup target add $(android_triples)

$(foreach triple, $(android_triples), \
Expand Down
2 changes: 2 additions & 0 deletions platform/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ make ios_bindings

- Building android core:

Prerequisite: You should install NDK (it is recommended to use Android Studio for installing it). Version r24 should be installed. Make sure that either `NDK_HOME` or `ANDROID_NDK_HOME`(specifying the path to NDK) is exported as an environment variable on your system.

```shell
make android_bindings
```
Expand Down

This file was deleted.

0 comments on commit 4e565b8

Please sign in to comment.