Skip to content
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

Make rust core use NDK >= r23 #1086

Merged
merged 13 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
25 changes: 12 additions & 13 deletions platform/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ 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))
# Android NDK fix
# This is required due to Rust still using lgcc for NDK,
# which was made osbsolete starting with NDK r23 in favor of lunwind.
# The solution is to create a libgcc.a file in every clang architecture, which will link to -ilunwind.
clang_path = ${ANDROID_NDK_HOME}/*/toolchains/llvm/prebuilt/*/lib64/clang/*/lib/*
ndk_archs = aarch64 arm i386 x86_64
JJ marked this conversation as resolved.
Show resolved Hide resolved
libgcc_paths = $(patsubst %, $(clang_path)/%/libgcc.a, $(ndk_archs))
JJ marked this conversation as resolved.
Show resolved Hide resolved

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



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

$(target):
Expand Down Expand Up @@ -100,13 +101,11 @@ endef

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

$(ndk):
mkdir -p $(ndk)
curl -L $(ndk_download_url) -o $(ndk_archive)
unzip -q -d $(ndk) $(ndk_archive)
rm $(ndk_archive)
$(libgcc_paths):
# Create a libgcc.a file that links to lunwind for a given ndk architecture.
$(os_echo) "INPUT(-lunwind)" >> $@
JJ marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
3 changes: 3 additions & 0 deletions platform/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ make ios_bindings

- Building android core:

Prerequisites:
- You should install NDK(it is recommended to use Android Studio). A version >= r23 is required.
GhenadiePusca marked this conversation as resolved.
Show resolved Hide resolved

```shell
make android_bindings
```
Expand Down

This file was deleted.