From 2b7d6745eab4cf8de256b109200bc2c59923ef20 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Fri, 4 Jul 2025 22:31:25 +0800 Subject: [PATCH] Simplify native build --- ...le-runtime-detection-of-NEON-support.patch | 25 ------------------- ...ch => 0001-Fix-zip_time-performance.patch} | 0 app/src/main/cpp/0001-Insert-link-libs.patch | 25 ------------------- ...-UTF-8-as-default-charset-on-bionic.patch} | 0 app/src/main/cpp/CMakeLists.txt | 24 +++++++++--------- 5 files changed, 12 insertions(+), 62 deletions(-) delete mode 100644 app/src/main/cpp/0001-Disable-runtime-detection-of-NEON-support.patch rename app/src/main/cpp/{0002-Fix-zip_time-performance.patch => 0001-Fix-zip_time-performance.patch} (100%) delete mode 100644 app/src/main/cpp/0001-Insert-link-libs.patch rename app/src/main/cpp/{0003-Use-UTF-8-as-default-charset-on-bionic.patch => 0002-Use-UTF-8-as-default-charset-on-bionic.patch} (100%) diff --git a/app/src/main/cpp/0001-Disable-runtime-detection-of-NEON-support.patch b/app/src/main/cpp/0001-Disable-runtime-detection-of-NEON-support.patch deleted file mode 100644 index fd3e522ae..000000000 --- a/app/src/main/cpp/0001-Disable-runtime-detection-of-NEON-support.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 07931ec2f127ce2408690cc85399ca750ca12657 Mon Sep 17 00:00:00 2001 -From: FooIbar <118464521+FooIbar@users.noreply.github.com> -Date: Thu, 19 Jun 2025 00:03:46 +0800 -Subject: [PATCH] Disable runtime detection of NEON support - ---- - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index d7e8963f..9dda3bb1 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -181,7 +181,7 @@ endif() - - # ############################################################################## - # Android only. --if(ANDROID) -+if(0) - include_directories(${ANDROID_NDK}/sources/android/cpufeatures) - add_library(cpufeatures-webp STATIC - ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) --- -2.45.2 - diff --git a/app/src/main/cpp/0002-Fix-zip_time-performance.patch b/app/src/main/cpp/0001-Fix-zip_time-performance.patch similarity index 100% rename from app/src/main/cpp/0002-Fix-zip_time-performance.patch rename to app/src/main/cpp/0001-Fix-zip_time-performance.patch diff --git a/app/src/main/cpp/0001-Insert-link-libs.patch b/app/src/main/cpp/0001-Insert-link-libs.patch deleted file mode 100644 index 84208c43c..000000000 --- a/app/src/main/cpp/0001-Insert-link-libs.patch +++ /dev/null @@ -1,25 +0,0 @@ -From aee8f7147ddb262fd9e5feee8d5b17094cf3470f Mon Sep 17 00:00:00 2001 -From: FooIbar <118464521+FooIbar@users.noreply.github.com> -Date: Tue, 26 Sep 2023 00:09:25 +0800 -Subject: [PATCH] Insert link libs - ---- - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index ec97e4c7..420f204c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -438,7 +438,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") - # # endif - ENDIF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") - --SET(ADDITIONAL_LIBS "") -+SET(ADDITIONAL_LIBS ${LIBARCHIVE_CUSTOM_LIBS}) - # - # Find ZLIB - # --- -2.34.1 - diff --git a/app/src/main/cpp/0003-Use-UTF-8-as-default-charset-on-bionic.patch b/app/src/main/cpp/0002-Use-UTF-8-as-default-charset-on-bionic.patch similarity index 100% rename from app/src/main/cpp/0003-Use-UTF-8-as-default-charset-on-bionic.patch rename to app/src/main/cpp/0002-Use-UTF-8-as-default-charset-on-bionic.patch diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 0bc61eb6d..a6073b9d0 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -37,7 +37,7 @@ FetchContent_MakeAvailable(liblzma) include_directories(${liblzma_SOURCE_DIR}/src/liblzma/api) # Build GNUTLS libnettle -if (CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) +if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") execute_process( COMMAND wsl wslpath ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE CURRENT_DIR @@ -49,16 +49,15 @@ endif () set(NDK_VERSION "${ANDROID_NDK_MAJOR}.${ANDROID_NDK_MINOR}.${ANDROID_NDK_BUILD}") ExternalProject_Add( nettle - PREFIX nettle GIT_REPOSITORY https://gitlab.com/gnutls/nettle.git GIT_TAG nettle_3.10.2_release_20250626 GIT_SHALLOW 1 GIT_CONFIG core.autocrlf=input CONFIGURE_COMMAND bash ${CURRENT_DIR}/configure_nettle.sh ${NDK_VERSION} ${CMAKE_C_COMPILER_TARGET} - BUILD_COMMAND bash -c "make libnettle.a CFLAGS='${CMAKE_C_FLAGS} -Qunused-arguments'" + BUILD_COMMAND bash -c "make -j4 libnettle.a CFLAGS='${CMAKE_C_FLAGS} -Qunused-arguments'" INSTALL_COMMAND "" BUILD_IN_SOURCE 1 - BUILD_BYPRODUCTS nettle/src/nettle/libnettle.a + BUILD_BYPRODUCTS /libnettle.a ) ExternalProject_Get_Property(nettle SOURCE_DIR) @@ -90,13 +89,9 @@ option(ENABLE_CAT OFF) option(ENABLE_UNZIP OFF) option(ENABLE_TEST OFF) -# Configure libarchive link's static lib -SET(LIBARCHIVE_CUSTOM_LIBS "libnettle" "liblzma") - set(LIBARCHIVE_PATCH - ${CMAKE_CURRENT_LIST_DIR}/0001-Insert-link-libs.patch - ${CMAKE_CURRENT_LIST_DIR}/0002-Fix-zip_time-performance.patch - ${CMAKE_CURRENT_LIST_DIR}/0003-Use-UTF-8-as-default-charset-on-bionic.patch + ${CMAKE_CURRENT_LIST_DIR}/0001-Fix-zip_time-performance.patch + ${CMAKE_CURRENT_LIST_DIR}/0002-Use-UTF-8-as-default-charset-on-bionic.patch ) FetchContent_Declare( libarchive @@ -107,15 +102,14 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(libarchive) +target_link_libraries(archive_static liblzma libnettle) include_directories(${libarchive_SOURCE_DIR}/libarchive) -set(LIBWEBP_PATCH ${CMAKE_CURRENT_LIST_DIR}/0001-Disable-runtime-detection-of-NEON-support.patch) FetchContent_Declare( libwebp GIT_REPOSITORY https://chromium.googlesource.com/webm/libwebp GIT_TAG v1.5.0 GIT_SHALLOW 1 - PATCH_COMMAND git apply --check -R ${LIBWEBP_PATCH} || git apply ${LIBWEBP_PATCH} ) option(WEBP_BUILD_ANIM_UTILS OFF) @@ -127,7 +121,13 @@ option(WEBP_BUILD_LIBWEBPMUX OFF) option(WEBP_BUILD_EXTRAS OFF) option(WEBP_ENABLE_SWAP_16BIT_CSP ON) +# Disable runtime detection of NEON support as NEON is required since API level 23 +# https://source.android.com/docs/compatibility/6.0/android-6.0-cdd#3_3_1_application_binary_interfaces +unset(ANDROID) FetchContent_MakeAvailable(libwebp) +if (CMAKE_SYSTEM_NAME STREQUAL "Android") + set(ANDROID 1) +endif () FetchContent_Declare( Corrosion