Skip to content

Commit

Permalink
build: update NDK to r27
Browse files Browse the repository at this point in the history
If we are dropping Android 4 support anyway,
can as well upgrade to the current LTS NDK
which requires API level 21 (Android 5.0).
  • Loading branch information
link2xt committed Aug 14, 2024
1 parent a50d8b9 commit 851d9b9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preview-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r23c
ndk-version: r27

- name: Compile core
env:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ ENV PATH ${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/bin
#
# If you change the NDK version here, also change it in `flake.nix`.
# NDK version r23c LTS aka 23.2.8568313
RUN sdkmanager --sdk_root=${ANDROID_SDK_ROOT} 'ndk;23.2.8568313'
RUN sdkmanager --sdk_root=${ANDROID_SDK_ROOT} 'ndk;27.0.11902837'

ENV ANDROID_NDK_ROOT ${ANDROID_SDK_ROOT}/ndk/23.2.8568313
ENV ANDROID_NDK_ROOT ${ANDROID_SDK_ROOT}/ndk/27.0.11902837
ENV PATH ${PATH}:${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
// > Task :stripFatDebugDebugSymbols
// Unable to strip the following libraries, packaging them as they are: libanimation-decoder-gif.so, libnative-utils.so.
// See <https://issuetracker.google.com/issues/237187538> for details.
ndkVersion "23.2.8568313"
ndkVersion "27.0.12077973"
useLibrary 'org.apache.http.legacy'

defaultConfig {
Expand Down
76 changes: 21 additions & 55 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
ndk-bundle
platform-tools
platforms-android-34
ndk-23-2-8568313
ndk-27-0-11902837
]);
rust-version = pkgs.lib.removeSuffix "\n"
(builtins.readFile ./scripts/rust-toolchain);
in {
devShells.default = pkgs.mkShell {
ANDROID_SDK_ROOT = "${android-sdk}/share/android-sdk";
ANDROID_NDK_ROOT =
"${android-sdk}/share/android-sdk/ndk/23.2.8568313";
"${android-sdk}/share/android-sdk/ndk/27.0.11902837";
buildInputs = [
android-sdk
pkgs.openjdk17
Expand Down
51 changes: 0 additions & 51 deletions jni/dc_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,6 @@
#include "deltachat-core-rust/deltachat-ffi/deltachat.h"


#if __ANDROID_API__ == 16
unsigned long getauxval(unsigned long type) {
return 0;
}

#include <sys/socket.h>
#include <unistd.h>

int sendmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen,
int flags)
{
if (flags != 0) {
// Not supported by the fallback.
return -1;
}

if (vlen == 0) {
return 0;
}

ssize_t n = sendmsg(sockfd, &msgvec->msg_hdr, flags);
if (n == -1) {
return -1;
}

(*msgvec).msg_len = n;
return 1;
}

int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen,
int flags, struct timespec *timeout)
{
if (flags != 0) {
// Not supported by the fallback.
return -1;
}

if (vlen == 0) {
return 0;
}

int n = recvmsg(sockfd, &msgvec->msg_hdr, flags);
if (n == -1) {
return -1;
}
(*msgvec).msg_len = n;
return 1;
}
#endif


static dc_msg_t* get_dc_msg(JNIEnv *env, jobject obj);


Expand Down
8 changes: 4 additions & 4 deletions scripts/ndk-make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ fi
unset RUSTFLAGS

TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$NDK_HOST_TAG"
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="$TOOLCHAIN/bin/armv7a-linux-androideabi16-clang"
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="$TOOLCHAIN/bin/armv7a-linux-androideabi21-clang"
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$TOOLCHAIN/bin/aarch64-linux-android21-clang"
export CARGO_TARGET_I686_LINUX_ANDROID_LINKER="$TOOLCHAIN/bin/i686-linux-android16-clang"
export CARGO_TARGET_I686_LINUX_ANDROID_LINKER="$TOOLCHAIN/bin/i686-linux-android21-clang"
export CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="$TOOLCHAIN/bin/x86_64-linux-android21-clang"

export RUSTUP_TOOLCHAIN=$(cat "$(dirname "$0")/rust-toolchain")
Expand Down Expand Up @@ -116,7 +116,7 @@ unset CPATH

if test -z $1 || test $1 = armeabi-v7a; then
echo "-- cross compiling to armv7-linux-androideabi (arm) --"
TARGET_CC="$TOOLCHAIN/bin/armv7a-linux-androideabi16-clang" \
TARGET_CC="$TOOLCHAIN/bin/armv7a-linux-androideabi21-clang" \
TARGET_AR="$TOOLCHAIN/bin/llvm-ar" \
TARGET_RANLIB="$TOOLCHAIN/bin/llvm-ranlib" \
cargo build $RELEASEFLAG --target armv7-linux-androideabi -p deltachat_ffi --features jsonrpc
Expand All @@ -134,7 +134,7 @@ fi

if test -z $1 || test $1 = x86; then
echo "-- cross compiling to i686-linux-android (x86) --"
TARGET_CC="$TOOLCHAIN/bin/i686-linux-android16-clang" \
TARGET_CC="$TOOLCHAIN/bin/i686-linux-android21-clang" \
TARGET_AR="$TOOLCHAIN/bin/llvm-ar" \
TARGET_RANLIB="$TOOLCHAIN/bin/llvm-ranlib" \
cargo build $RELEASEFLAG --target i686-linux-android -p deltachat_ffi --features jsonrpc
Expand Down

0 comments on commit 851d9b9

Please sign in to comment.