Problem: Android build scripts does not work with latest NDK versions

Solution: Update the build scripts to work with NDK versions r23 and r24
This commit is contained in:
Benjamin Deroche 2022-05-09 12:15:24 +02:00
parent edfbb1ced6
commit d1ee71a634
5 changed files with 34 additions and 18 deletions

View File

@ -23,7 +23,7 @@ of platforms, where libzmq has been successfully compiled on.
| OS and version | Architecture | Compiler and version | Build system | Remarks |
|----------------------------------------|-------------------------|-------------------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------|
| Android NDK r20 | arm, arm64, x86, x86_64 | llvm (see NDK) | autotools | DRAFT |
| Android NDK r24 | arm, arm64, x86, x86_64 | llvm (see NDK) | autotools | DRAFT |
| Ubuntu 14.04.5 LTS (trusty) | amd64 | clang 5.0.0 | autotools | STABLE, extras: GSSAPI, PGM, NORM, C++98 mode only |
| Ubuntu 14.04.5 LTS (trusty) | amd64 | gcc 4.8.4 | autotools | STABLE, DRAFT, extras: GSSAPI, PGM, NORM, TIPC, IPV6, also POLLER=poll, POLLER=select, also valgrind and address sanitizer executions |
| Ubuntu 14.04.5 LTS (trusty) | amd64 | gcc 4.8.4 | CMake 3.12.2 | STABLE |

View File

@ -5,12 +5,12 @@
You need the Android Native Development Kit (NDK) installed. See
[here](https://developer.android.com/ndk) to download it.
This project is tested against Android NDK version r21d.
This project is tested against Android NDK version r24.
If you installed version r21e all you have to do is to expose the NDK root
If you installed version r24 all you have to do is to expose the NDK root
directory as environment variable, e.g:
export ANDROID_NDK_ROOT=$HOME/android-ndk-r21e
export ANDROID_NDK_ROOT=$HOME/android-ndk-r24
If you installed another version you have to expose the NDK root directory as
well as the NDK version, e.g:

View File

@ -112,12 +112,12 @@ function android_build_env {
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_BUILD_FAIL+=("Please set the ANDROID_NDK_ROOT environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r20\")")
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r24\")")
fi
if [ -z "$TOOLCHAIN_PATH" ]; then
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_PATH environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r20/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin\")")
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r24/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin\")")
fi
if [ -z "$TOOLCHAIN_HOST" ]; then
@ -181,10 +181,22 @@ function _android_build_opts_process_binaries {
else
local LD="${TOOLCHAIN_PATH}/ld"
fi
# Since NDK r24 this binary was removed due to LLVM being now the default
if [ ! -x "${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-as" ]; then
local AS="${TOOLCHAIN_PATH}/llvm-as"
else
local AS="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-as"
fi
# Since NDK r23 those binaries were removed due to LLVM being now the default
if [ ! -x "${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar" ]; then
local AR="${TOOLCHAIN_PATH}/llvm-ar"
local RANLIB="${TOOLCHAIN_PATH}/llvm-ranlib"
local STRIP="${TOOLCHAIN_PATH}/llvm-strip"
else
local AR="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar"
local RANLIB="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ranlib"
local STRIP="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-strip"
fi
if [ ! -x "${CC}" ]; then
ANDROID_BUILD_FAIL+=("The CC binary does not exist or is not executable")
@ -239,7 +251,12 @@ function android_build_opts {
_android_build_opts_process_binaries
# Since NDK r23 we don't need -lgcc due to LLVM being now the default
if [ ! -x "${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar" ]; then
local LIBS="-lc -ldl -lm -llog -lc++_shared"
else
local LIBS="-lc -lgcc -ldl -lm -llog -lc++_shared"
fi
local LDFLAGS="-L${ANDROID_BUILD_PREFIX}/lib"
LDFLAGS+=" -L${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${TOOLCHAIN_ABI}"
CFLAGS+=" -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE"

View File

@ -34,10 +34,9 @@ case $(uname | tr '[:upper:]' '[:lower:]') in
esac
# Set default values used in ci builds
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 NDK_VERSION=${NDK_VERSION:-android-ndk-r24}
# With NDK r22b, the minimum SDK version range is [16, 31].
# Since NDK r24, the minimum SDK version range is [19, 31].
export MIN_SDK_VERSION=${MIN_SDK_VERSION:-21}
# Set up android build environment and set ANDROID_BUILD_OPTS array

View File

@ -1,14 +1,14 @@
#!/usr/bin/env bash
export NDK_VERSION=android-ndk-r22b
export NDK_VERSION=android-ndk-r24
export ANDROID_NDK_ROOT="/tmp/${NDK_VERSION}"
case $(uname | tr '[:upper:]' '[:lower:]') in
linux*)
HOST_PLATFORM=linux-x86_64
HOST_PLATFORM=linux
;;
darwin*)
HOST_PLATFORM=darwin-x86_64
HOST_PLATFORM=darwin
;;
*)
echo "Unsupported platform"