Problem: Android build script isn't compatible with latest NDK version (#4278)

* Problem: Android build script isn't compatible with latest NDK version

Solution: Update to Android NDK r22b
This commit is contained in:
Benjamin Deroche 2021-10-18 11:05:10 +02:00 committed by GitHub
parent 7c2df78b49
commit 519e2bf129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -97,7 +97,12 @@ function android_build_set_env {
export TOOLCHAIN_ARCH="x86_64"
fi
export ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/platforms/android-${MIN_SDK_VERSION}/arch-${TOOLCHAIN_ARCH}"
# Since NDK r22 the "platforms" dir got removed
if [ -d "${ANDROID_NDK_ROOT}/platforms" ]; then
export ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/platforms/android-${MIN_SDK_VERSION}/arch-${TOOLCHAIN_ARCH}"
else
export ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/sysroot"
fi
export ANDROID_BUILD_PREFIX="${ANDROID_BUILD_DIR}/prefix/${TOOLCHAIN_ARCH}"
}
@ -170,7 +175,12 @@ function _android_build_opts_process_binaries {
local TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_PLATFORM}"
local CC="${TOOLCHAIN_PATH}/${TOOLCHAIN_COMP}-clang"
local CXX="${TOOLCHAIN_PATH}/${TOOLCHAIN_COMP}-clang++"
local LD="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ld"
# Since NDK r22 the "platforms" dir got removed and the default linker is LLD
if [ -d "${ANDROID_NDK_ROOT}/platforms" ]; then
local LD="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ld"
else
local LD="${TOOLCHAIN_PATH}/ld"
fi
local AS="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-as"
local AR="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar"
local RANLIB="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ranlib"

View File

@ -35,7 +35,7 @@ esac
# Set default values used in ci builds
export NDK_VERSION=${NDK_VERSION:-android-ndk-r21e}
export NDK_VERSION=${NDK_VERSION:-android-ndk-r22b}
# With NDK r21e, the minimum SDK version range is [16, 29].
# SDK version 21 is the minimum version for 64-bit builds.
export MIN_SDK_VERSION=${MIN_SDK_VERSION:-21}

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
export NDK_VERSION=android-ndk-r21e
export NDK_VERSION=android-ndk-r22b
export ANDROID_NDK_ROOT="/tmp/${NDK_VERSION}"
case $(uname | tr '[:upper:]' '[:lower:]') in