Skip to content

Commit

Permalink
build: updated Android NDK from r21 to r25b (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare authored Nov 8, 2022
1 parent 9ad93a8 commit 6f1d5b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions aw-server/src/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub mod android {
.new_string(world_ptr.to_str().unwrap())
.expect("Couldn't create java string!");

output.into_inner()
output.into_raw()
}

unsafe fn jstring_to_string(env: &JNIEnv, string: JString) -> String {
Expand All @@ -85,7 +85,7 @@ pub mod android {
unsafe fn string_to_jstring(env: &JNIEnv, string: String) -> jstring {
env.new_string(string)
.expect("Couldn't create java string")
.into_inner()
.into_raw()
}

unsafe fn create_error_object(env: &JNIEnv, msg: String) -> jstring {
Expand Down
5 changes: 5 additions & 0 deletions compile-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ for archtargetstr in \
; do
arch=$(echo $archtargetstr | cut -d " " -f 1)
target=$(echo $archtargetstr | cut -d " " -f 2)
target_underscore=$(echo $target | sed 's/-/_/g')

NDK_ARCH_DIR="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
echo "Building for $arch..."

if [ -d "$NDK_ARCH_DIR" ]; then
export PATH="$NDK_ARCH_DIR:$ORIG_PATH"
# Need to set AR for target since NDK 21+:
# https://github.com/rust-lang/cc-rs/issues/636#issuecomment-1075352495
declare -x "AR_${target_underscore}"="$NDK_ARCH_DIR/llvm-ar"
cargo build -p aw-server --target $target --lib $($RELEASE && echo '--release')
else
echo "Couldn't find directory $NDK_ARCH_DIR"
Expand Down
10 changes: 5 additions & 5 deletions install-ndk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ -z "$ANDROID_NDK_HOME" ]; then
echo "Found NDK folder in root, using."
else
echo 'ANDROID_NDK_HOME not set, downloading NDK...';
wget --no-verbose -O android-ndk.zip https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip;
wget --no-verbose -O android-ndk.zip https://dl.google.com/android/repository/android-ndk-r25b-linux.zip;
unzip -q -d NDK android-ndk.zip;
ls NDK;
mv NDK/*/* NDK/;
Expand Down Expand Up @@ -44,18 +44,18 @@ echo "Creating cargo config..."
mkdir -p $project_path/.cargo
echo "
[target.aarch64-linux-android]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar'
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang'
[target.armv7-linux-androideabi]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi-ar'
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi-clang'
[target.i686-linux-android]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android-ar'
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android26-clang'
[target.x86_64-linux-android]
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-ar'
ar = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
linker = '$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang'
" > $project_path/.cargo/config

0 comments on commit 6f1d5b2

Please sign in to comment.