From fd9164422149d65dfae4eba400f11c7dccccaa39 Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Thu, 1 Sep 2022 23:24:40 +0100 Subject: [PATCH] support newer android ndk versions --- .github/workflows/android-build-scripts.yml | 8 +- .github/workflows/periodic-builds-android.yml | 4 +- android/jni/Android.mk | 8 +- scripts/android/dav1d.sh | 3 +- scripts/android/gnutls.sh | 3 + scripts/android/libvpx.sh | 6 +- scripts/function-android.sh | 80 ++++++++----------- 7 files changed, 55 insertions(+), 57 deletions(-) diff --git a/.github/workflows/android-build-scripts.yml b/.github/workflows/android-build-scripts.yml index 30546be..eccf219 100644 --- a/.github/workflows/android-build-scripts.yml +++ b/.github/workflows/android-build-scripts.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - ndk-version: [ 'r22b-linux-x86_64', 'r23b-linux' ] + ndk-version: [ 'r22b-linux-x86_64', 'r23b-linux', 'r24-linux', 'r25b-linux' ] defaults: run: shell: bash @@ -39,7 +39,7 @@ jobs: unzip -q -o ndk.zip -d .ndk echo "ANDROID_NDK_ROOT=$PWD/.ndk/$(ls .ndk)" >> $GITHUB_ENV - name: run the build script - run: ./android.sh -d --enable-android-media-codec --enable-android-zlib + run: ./android.sh -d --enable-android-media-codec --enable-android-zlib --disable-arm-v7a - name: print build logs if: ${{ always() }} run: cat build.log @@ -80,7 +80,7 @@ jobs: runs-on: macos-10.15 strategy: matrix: - ndk-version: [ 'r22b-darwin-x86_64', 'r23b-darwin' ] + ndk-version: [ 'r22b-darwin-x86_64', 'r23b-darwin', 'r24-darwin', 'r25b-darwin' ] defaults: run: shell: bash @@ -97,7 +97,7 @@ jobs: unzip -q -o ndk.zip -d .ndk echo "ANDROID_NDK_ROOT=$PWD/.ndk/$(ls .ndk)" >> $GITHUB_ENV - name: run the build script - run: ./android.sh -d --enable-android-media-codec --enable-android-zlib + run: ./android.sh -d --enable-android-media-codec --enable-android-zlib --disable-arm-v7a - name: print build logs if: ${{ always() }} run: cat build.log diff --git a/.github/workflows/periodic-builds-android.yml b/.github/workflows/periodic-builds-android.yml index 9b4543b..27f31f4 100644 --- a/.github/workflows/periodic-builds-android.yml +++ b/.github/workflows/periodic-builds-android.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - ndk-version: [ 'r22b-linux-x86_64', 'r23b-linux' ] + ndk-version: [ 'r22b-linux-x86_64', 'r23b-linux', 'r24-linux', 'r25b-linux' ] branches: [ 'main', 'development' ] defaults: run: @@ -34,7 +34,7 @@ jobs: unzip -q -o ndk.zip -d .ndk echo "ANDROID_NDK_ROOT=$PWD/.ndk/$(ls .ndk)" >> $GITHUB_ENV - name: run the build script - run: ./android.sh --full --enable-gpl --disable-lib-srt + run: ./android.sh --full --enable-gpl --disable-lib-srt --disable-arm-v7a - name: print build logs if: ${{ always() }} run: cat build.log diff --git a/android/jni/Android.mk b/android/jni/Android.mk index ed37c47..07d9c66 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -37,7 +37,11 @@ LOCAL_PATH := $(MY_LOCAL_PATH)/../ffmpeg-kit-android-lib/src/main/cpp # DEFINE ARCH FLAGS ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) MY_ARCH_FLAGS := ARM_V7A - MY_ARM_NEON := false + ifeq ("$(shell test -e $(MY_LOCAL_PATH)/../build/.lts && echo lts)","lts") + MY_ARM_NEON := false + else + MY_ARM_NEON := true + endif endif ifeq ($(TARGET_ARCH_ABI), arm64-v8a) MY_ARCH_FLAGS := ARM64_V8A @@ -45,9 +49,11 @@ ifeq ($(TARGET_ARCH_ABI), arm64-v8a) endif ifeq ($(TARGET_ARCH_ABI), x86) MY_ARCH_FLAGS := X86 + MY_ARM_NEON := true endif ifeq ($(TARGET_ARCH_ABI), x86_64) MY_ARCH_FLAGS := X86_64 + MY_ARM_NEON := true endif include $(CLEAR_VARS) diff --git a/scripts/android/dav1d.sh b/scripts/android/dav1d.sh index e6644c1..9b12f14 100644 --- a/scripts/android/dav1d.sh +++ b/scripts/android/dav1d.sh @@ -8,9 +8,10 @@ create_mason_cross_file "$CROSS_FILE" || return 1 # ALWAYS CLEAN THE PREVIOUS BUILD rm -rf "${BUILD_DIR}" || return 1 +# ENABLING LTO CAUSES SYMBOL NOT FOUND ERRORS ON NDKS >= 23b meson "${BUILD_DIR}" \ --cross-file="$CROSS_FILE" \ - -Db_lto=true \ + -Db_lto=false \ -Db_ndebug=false \ -Denable_asm=false \ -Denable_tools=false \ diff --git a/scripts/android/gnutls.sh b/scripts/android/gnutls.sh index ff937ef..527df28 100755 --- a/scripts/android/gnutls.sh +++ b/scripts/android/gnutls.sh @@ -31,6 +31,9 @@ if [[ ! -f "${BASEDIR}"/src/"${LIB_NAME}"/configure ]] || [[ ${RECONF_gnutls} -e ./bootstrap || return 1 fi +# MASKING THE -march=all OPTION WHICH BREAKS THE BUILD ON arm64-v8a +${SED_INLINE} "s|AM_CCASFLAGS =|#AM_CCASFLAGS=|g" "${BASEDIR}"/src/"${LIB_NAME}"/lib/accelerated/aarch64/Makefile.in + ./configure \ --prefix="${LIB_INSTALL_PREFIX}" \ --with-pic \ diff --git a/scripts/android/libvpx.sh b/scripts/android/libvpx.sh index 91f5378..162a7d4 100755 --- a/scripts/android/libvpx.sh +++ b/scripts/android/libvpx.sh @@ -13,17 +13,17 @@ arm-v7a) # NEON disabled explicitly because # --enable-runtime-cpu-detect enables NEON for armv7 cpu ASM_OPTIONS="--disable-neon" - unset ASFLAGS + export ASFLAGS="-c" ;; arm-v7a-neon) # NEON IS ENABLED BY --enable-runtime-cpu-detect TARGET_CPU="armv7" - unset ASFLAGS + export ASFLAGS="-c" ;; arm64-v8a) # NEON IS ENABLED BY --enable-runtime-cpu-detect TARGET_CPU="arm64" - unset ASFLAGS + export ASFLAGS="-c" ;; *) # INTEL CPU EXTENSIONS ENABLED BY --enable-runtime-cpu-detect diff --git a/scripts/function-android.sh b/scripts/function-android.sh index a5d17d6..99b619c 100755 --- a/scripts/function-android.sh +++ b/scripts/function-android.sh @@ -227,14 +227,11 @@ get_common_cflags() { local LTS_BUILD_FLAG="-DFFMPEG_KIT_LTS " fi - case ${DETECTED_NDK_VERSION} in - 23*) - echo "-fstrict-aliasing -DANDROID_NDK -fPIC -DANDROID ${LTS_BUILD_FLAG}-D__ANDROID__ -D__ANDROID_MIN_SDK_VERSION__=${API}" - ;; - *) - echo "-fno-integrated-as -fstrict-aliasing -DANDROID_NDK -fPIC -DANDROID ${LTS_BUILD_FLAG}-D__ANDROID__ -D__ANDROID_API__=${API}" - ;; - esac + if [[ $(compare_versions "$DETECTED_NDK_VERSION" "23") -ge 0 ]]; then + echo "-fstrict-aliasing -DANDROID_NDK -fPIC -DANDROID ${LTS_BUILD_FLAG}-D__ANDROID__ -D__ANDROID_MIN_SDK_VERSION__=${API}" + else + echo "-fno-integrated-as -fstrict-aliasing -DANDROID_NDK -fPIC -DANDROID ${LTS_BUILD_FLAG}-D__ANDROID__ -D__ANDROID_API__=${API}" + fi } get_arch_specific_cflags() { @@ -249,24 +246,18 @@ get_arch_specific_cflags() { echo "-march=armv8-a -DFFMPEG_KIT_ARM64_V8A" ;; x86) - case ${DETECTED_NDK_VERSION} in - 23*) - echo "-march=i686 -mtune=generic -mssse3 -mfpmath=sse -m32 -DFFMPEG_KIT_X86" - ;; - *) - echo "-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -DFFMPEG_KIT_X86" - ;; - esac + if [[ $(compare_versions "$DETECTED_NDK_VERSION" "23") -ge 0 ]]; then + echo "-march=i686 -mtune=generic -mssse3 -mfpmath=sse -m32 -DFFMPEG_KIT_X86" + else + echo "-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -DFFMPEG_KIT_X86" + fi ;; x86-64) - case ${DETECTED_NDK_VERSION} in - 23*) - echo "-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=generic -DFFMPEG_KIT_X86_64" - ;; - *) - echo "-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -DFFMPEG_KIT_X86_64" - ;; - esac + if [[ $(compare_versions "$DETECTED_NDK_VERSION" "23") -ge 0 ]]; then + echo "-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=generic -DFFMPEG_KIT_X86_64" + else + echo "-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -DFFMPEG_KIT_X86_64" + fi ;; esac } @@ -1037,33 +1028,30 @@ set_toolchain_paths() { export CC=$(get_clang_host)-clang export CXX=$(get_clang_host)-clang++ - if [ "$1" == "x264" ]; then - export AS=${CC} - else - export AS=${HOST}-as - fi - case ${ARCH} in arm64-v8a) export ac_cv_c_bigendian=no ;; esac - case ${DETECTED_NDK_VERSION} in - 23*) - export AR=llvm-ar - export LD=lld - export RANLIB=llvm-ranlib - export STRIP=llvm-strip - export NM=llvm-nm - ;; - *) - export AR=${HOST}-ar - export LD=${HOST}-ld - export RANLIB=${HOST}-ranlib - export STRIP=${HOST}-strip - export NM=${HOST}-nm - ;; - esac + if [[ $(compare_versions "$DETECTED_NDK_VERSION" "23") -ge 0 ]]; then + export AR=llvm-ar + export LD=lld + export RANLIB=llvm-ranlib + export STRIP=llvm-strip + export NM=llvm-nm + export AS=$CC + else + export AR=${HOST}-ar + export LD=${HOST}-ld + export RANLIB=${HOST}-ranlib + export STRIP=${HOST}-strip + export NM=${HOST}-nm + if [ "$1" == "x264" ]; then + export AS=${CC} + else + export AS=${HOST}-as + fi + fi export INSTALL_PKG_CONFIG_DIR="${BASEDIR}"/prebuilt/$(get_build_directory)/pkgconfig export ZLIB_PACKAGE_CONFIG_PATH="${INSTALL_PKG_CONFIG_DIR}/zlib.pc"