use x86-64 ndk toolchain on arm64 darwin hosts, fixes #175

This commit is contained in:
Taner Sener 2021-10-07 20:58:42 +01:00
parent fb0a2105a0
commit d0ddcaf4df
2 changed files with 22 additions and 1 deletions

View File

@ -296,7 +296,11 @@ if [[ -n ${ANDROID_ARCHITECTURES} ]]; then
# BUILD NATIVE LIBRARY
if [[ ${SKIP_ffmpeg_kit} -ne 1 ]]; then
"${ANDROID_NDK_ROOT}"/ndk-build -B 1>>"${BASEDIR}"/build.log 2>&1
if [ "$(is_darwin_arm64)" == "1" ]; then
arch -x86_64 "${ANDROID_NDK_ROOT}"/ndk-build -B 1>>"${BASEDIR}"/build.log 2>&1
else
"${ANDROID_NDK_ROOT}"/ndk-build -B 1>>"${BASEDIR}"/build.log 2>&1
fi
if [ $? -eq 0 ]; then
echo "ok"

View File

@ -109,6 +109,17 @@ get_clang_host() {
esac
}
is_darwin_arm64() {
HOST_OS=$(uname -s)
HOST_ARCH=$(uname -m)
if [ "${HOST_OS}" == "Darwin" ] && [ "${HOST_ARCH}" == "arm64" ]; then
echo "1"
else
echo "0"
fi
}
get_toolchain() {
HOST_OS=$(uname -s)
case ${HOST_OS} in
@ -124,6 +135,12 @@ get_toolchain() {
x86_64 | amd64) HOST_ARCH=x86_64 ;;
esac
if [ "$(is_darwin_arm64)" == "1" ]; then
# NDK DOESNT HAVE AN ARM64 TOOLCHAIN ON DARWIN
# WE USE x86-64 WITH ROSETTA INSTEAD
HOST_ARCH=x86_64
fi
echo "${HOST_OS}-${HOST_ARCH}"
}