Update to Android NDK r23c

Android NDK is updated from legacy ndk-bundle stuck at unsupported
r22b to LTS NDK r23c (23.2.8568313).

Since GNU binutils have been removed from NDK since r23 (see
https://github.com/android/ndk/wiki/Changelog-r23), ndk-make.sh now
uses TARGET_AR=llvm-ar and uses a workaround for `-lgcc` requirement.

Android command line tools used in the Dockerfile are updated to build
8512546

Preview APKs now use NDK r23c too.
This commit is contained in:
link2xt
2022-05-28 16:08:11 +00:00
parent dadb12e664
commit af772762ef
3 changed files with 26 additions and 12 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ jobs:
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21d
ndk-version: r23c
- name: Compile core
env:
+9 -7
View File
@@ -23,18 +23,20 @@ USER $USER
ENV ANDROID_SDK_ROOT /home/${USER}/android-sdk
RUN mkdir ${ANDROID_SDK_ROOT}
WORKDIR $ANDROID_SDK_ROOT
RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip && \
unzip commandlinetools-linux-6200805_latest.zip && \
rm commandlinetools-linux-6200805_latest.zip
RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip && \
unzip commandlinetools-linux-8512546_latest.zip && \
rm commandlinetools-linux-8512546_latest.zip
RUN yes | ${ANDROID_SDK_ROOT}/tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} --licenses
RUN yes | ${ANDROID_SDK_ROOT}/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} --licenses
ENV PATH ${PATH}:${ANDROID_SDK_ROOT}/tools/bin
ENV PATH ${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/bin
# Install NDK manually. Other SDK parts are installed automatically by gradle.
RUN sdkmanager --sdk_root=${ANDROID_SDK_ROOT} ndk-bundle
#
# NDK version r23c LTS aka 23.2.8568313
RUN sdkmanager --sdk_root=${ANDROID_SDK_ROOT} 'ndk;23.2.8568313'
ENV ANDROID_NDK_ROOT ${ANDROID_SDK_ROOT}/ndk-bundle
ENV ANDROID_NDK_ROOT ${ANDROID_SDK_ROOT}/ndk/23.2.8568313
ENV PATH ${PATH}:${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/:${ANDROID_NDK_ROOT}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
+16 -4
View File
@@ -89,11 +89,18 @@ else
RELEASEFLAG=
fi
# Work around the bug in the build of Rust standard library.
# It is built against r22b NDK toolchains and still requires -lgcc instead of -lunwind used in newer r23 NDK.
# See discussion at <https://github.com/rust-lang/rust/pull/85806>
TMPLIB="$(mktemp -d)"
echo 'INPUT(-lunwind)' >"$TMPLIB/libgcc.a"
if test -z $1 || test $1 = armeabi-v7a; then
echo "-- cross compiling to armv7-linux-androideabi (arm) --"
export CFLAGS=-D__ANDROID_API__=16
TARGET_CC=armv7a-linux-androideabi16-clang \
cargo +`cat rust-toolchain` build $RELEASEFLAG --target armv7-linux-androideabi -p deltachat_ffi
TARGET_AR=llvm-ar \
cargo +`cat rust-toolchain` rustc $RELEASEFLAG --target armv7-linux-androideabi -p deltachat_ffi -- -L "$TMPLIB"
cp target/armv7-linux-androideabi/$RELEASE/libdeltachat.a $jnidir/armeabi-v7a
fi
@@ -101,7 +108,8 @@ if test -z $1 || test $1 = arm64-v8a; then
echo "-- cross compiling to aarch64-linux-android (arm64) --"
export CFLAGS=-D__ANDROID_API__=21
TARGET_CC=aarch64-linux-android21-clang \
cargo +`cat rust-toolchain` build $RELEASEFLAG --target aarch64-linux-android -p deltachat_ffi
TARGET_AR=llvm-ar \
cargo +`cat rust-toolchain` rustc $RELEASEFLAG --target aarch64-linux-android -p deltachat_ffi -- -L "$TMPLIB"
cp target/aarch64-linux-android/$RELEASE/libdeltachat.a $jnidir/arm64-v8a
fi
@@ -109,7 +117,8 @@ if test -z $1 || test $1 = x86; then
echo "-- cross compiling to i686-linux-android (x86) --"
export CFLAGS=-D__ANDROID_API__=16
TARGET_CC=i686-linux-android16-clang \
cargo +`cat rust-toolchain` build $RELEASEFLAG --target i686-linux-android -p deltachat_ffi
TARGET_AR=llvm-ar \
cargo +`cat rust-toolchain` rustc $RELEASEFLAG --target i686-linux-android -p deltachat_ffi -- -L "$TMPLIB"
cp target/i686-linux-android/$RELEASE/libdeltachat.a $jnidir/x86
fi
@@ -117,10 +126,13 @@ if test -z $1 || test $1 = x86_64; then
echo "-- cross compiling to x86_64-linux-android (x86_64) --"
export CFLAGS=-D__ANDROID_API__=21
TARGET_CC=x86_64-linux-android21-clang \
cargo +`cat rust-toolchain` build $RELEASEFLAG --target x86_64-linux-android -p deltachat_ffi
TARGET_AR=llvm-ar \
cargo +`cat rust-toolchain` rustc $RELEASEFLAG --target x86_64-linux-android -p deltachat_ffi -- -L "$TMPLIB"
cp target/x86_64-linux-android/$RELEASE/libdeltachat.a $jnidir/x86_64
fi
rm -fr "$TMPLIB"
echo -- ndk-build --
cd ..