From a0db676d65201679b265b158b65d5d908b1a07a3 Mon Sep 17 00:00:00 2001 From: Mathias-Boulay Date: Tue, 16 Apr 2024 09:02:42 +0200 Subject: [PATCH] Build(perf): reuse existing ndk if available --- Dockerfile_port | 13 ++++++++++++- ci_build_global.sh | 11 ++++++++--- extractndk.sh | 2 -- maketoolchain.sh | 12 ------------ setdevkitpath.sh | 14 ++++++++------ 5 files changed, 28 insertions(+), 24 deletions(-) delete mode 100755 extractndk.sh delete mode 100755 maketoolchain.sh diff --git a/Dockerfile_port b/Dockerfile_port index 5ad9b0c..c3df024 100644 --- a/Dockerfile_port +++ b/Dockerfile_port @@ -32,7 +32,18 @@ RUN apt-get install -y \ # JDK 17 RUN apt-get install -y openjdk-17-jdk - WORKDIR /home + +# NDK install +ENV NDK_VERSION r25c +ENV ANDROID_NDK_HOME /home/android-ndk-$NDK_VERSION +RUN \ + wget -nc -nv -O android-ndk-$NDK_VERSION-linux-x86_64.zip "https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip" \ + && unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip \ + && rm android-ndk-$NDK_VERSION-linux-x86_64.zip + + + + COPY . . \ No newline at end of file diff --git a/ci_build_global.sh b/ci_build_global.sh index e33c7dc..2cf6bb0 100755 --- a/ci_build_global.sh +++ b/ci_build_global.sh @@ -5,9 +5,14 @@ set -e export JDK_DEBUG_LEVEL=release if [[ "$BUILD_IOS" != "1" ]]; then - wget -nc -nv -O android-ndk-$NDK_VERSION-linux-x86_64.zip "https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip" - ./extractndk.sh - ./maketoolchain.sh + if [[ -d "$ANDROID_NDK_HOME" ]]; then + echo "NDK already exists: $ANDROID_NDK_HOME" + else + echo "Downloading NDK" + wget -nc -nv -O android-ndk-$NDK_VERSION-linux-x86_64.zip "https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip" + unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip + fi + cp devkit.info.${TARGET_SHORT} ${TOOLCHAIN} else chmod +x ios-arm64-clang chmod +x ios-arm64-clang++ diff --git a/extractndk.sh b/extractndk.sh deleted file mode 100755 index 785ed36..0000000 --- a/extractndk.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip diff --git a/maketoolchain.sh b/maketoolchain.sh deleted file mode 100755 index 456079a..0000000 --- a/maketoolchain.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -e - -. setdevkitpath.sh - -# No need since all toolchains are standalone -# $NDK/build/tools/make_standalone_toolchain.py \ -# --arch=${TARGET_SHORT} \ -# --api=21 \ -# --install-dir=$NDK/generated-toolchains/android-${TARGET_SHORT}-toolchain - -cp devkit.info.${TARGET_SHORT} ${TOOLCHAIN} diff --git a/setdevkitpath.sh b/setdevkitpath.sh index c93828a..c80f6d3 100755 --- a/setdevkitpath.sh +++ b/setdevkitpath.sh @@ -44,19 +44,21 @@ if [[ "$BUILD_IOS" == "1" ]]; then else export JVM_PLATFORM=linux -# Set NDK export API=21 -export NDK=$PWD/android-ndk-$NDK_VERSION -export ANDROID_NDK_ROOT=$NDK -#export TOOLCHAIN=$NDK/generated-toolchains/android-${TARGET_SHORT}-toolchain -export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64 + +# Runners usually ship with a recent NDK already +if [[ -z "$ANDROID_NDK_HOME" ]] +then + export ANDROID_NDK_HOME=$PWD/android-ndk-$NDK_VERSION +fi + +export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64 export ANDROID_INCLUDE=$TOOLCHAIN/sysroot/usr/include # If I'm right it should only need the dummy libs export CPPFLAGS="-I$ANDROID_INCLUDE -I$ANDROID_INCLUDE/$TARGET" # -I/usr/include -I/usr/lib -#export LDFLAGS="-L$NDK/platforms/android-$API/arch-$TARGET_SHORT/usr/lib" export CPPFLAGS="" export LDFLAGS=""