From bb5ff57c2234fa69b518b9b17ba96610e870c2bd Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 24 Dec 2023 03:44:01 +0800 Subject: [PATCH] fix: try to fix android arch (#21) --- .github/workflows/build.yml | 19 ++++++++++------- .../scripts/remove_avoid-version.patch | 21 +++++++++++++++++++ .../maa-android-library-override.cmake | 5 +++++ vcpkg-overlay/triplets/maa-arm-android.cmake | 12 +++++++++++ .../triplets/maa-arm64-android.cmake | 1 + vcpkg-overlay/triplets/maa-x64-android.cmake | 1 + vcpkg-overlay/triplets/maa-x86-android.cmake | 11 ++++++++++ 7 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 vcpkg-overlay/scripts/remove_avoid-version.patch create mode 100644 vcpkg-overlay/triplets/maa-arm-android.cmake create mode 100644 vcpkg-overlay/triplets/maa-x86-android.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec7d705..6904952 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,6 @@ name: build on: push: - tags: "*" workflow_dispatch: inputs: use-cache: @@ -17,8 +16,11 @@ jobs: os: [ubuntu, windows, macos] arch: [x64, arm64] include: + # https://github.com/MaaAssistantArknights/MaaDeps/issues/20 + # - os: ubuntu + # arch: arm64-android - os: ubuntu - arch: arm64-android + arch: arm-android # clang-17: error: unsupported argument 'i686' to option '-march=' # https://github.com/MaaAssistantArknights/MaaDeps/actions/runs/7285060481/job/19851366697 # - os: ubuntu @@ -69,13 +71,16 @@ jobs: if: contains(matrix.arch, 'android') id: setup-ndk with: - # clang-17: error: unknown argument: '-avoid-version' - # https://github.com/MaaAssistantArknights/MaaDeps/actions/runs/7285134601/job/19851552458 - # https://github.com/microsoft/vcpkg/issues/31332 - # ndk-version: r26b - ndk-version: r25c + ndk-version: r26b add-to-path: false + # https://github.com/microsoft/vcpkg/issues/31332 + - name: Fix Android LDFLAGS error + if: contains(matrix.arch, 'android') + run: | + git -C vcpkg apply ../vcpkg-overlay/scripts/remove_avoid-version.patch + + - name: Install Packages on MacOS if: runner.os == 'macOS' run: | diff --git a/vcpkg-overlay/scripts/remove_avoid-version.patch b/vcpkg-overlay/scripts/remove_avoid-version.patch new file mode 100644 index 0000000..1941f3b --- /dev/null +++ b/vcpkg-overlay/scripts/remove_avoid-version.patch @@ -0,0 +1,21 @@ +diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake +index 6d6867da0f..3af1a3b9bc 100644 +--- a/scripts/cmake/vcpkg_configure_make.cmake ++++ b/scripts/cmake/vcpkg_configure_make.cmake +@@ -791,10 +791,12 @@ function(vcpkg_configure_make) + # https://www.gnu.org/software/libtool/manual/html_node/Link-mode.html + # -avoid-version is handled specially by libtool link mode, this flag is not forwarded to linker, + # and libtool tries to avoid versioning for shared libraries and no symbolic links are created. +- if(VCPKG_TARGET_IS_ANDROID) +- set(ENV{LDFLAGS} "-avoid-version $ENV{LDFLAGS}") +- set(ENV{LDFLAGS_FOR_BUILD} "-avoid-version $ENV{LDFLAGS_FOR_BUILD}") +- endif() ++ ++ # fix https://github.com/microsoft/vcpkg/issues/31332 ++ # if(VCPKG_TARGET_IS_ANDROID) ++ # set(ENV{LDFLAGS} "-avoid-version $ENV{LDFLAGS}") ++ # set(ENV{LDFLAGS_FOR_BUILD} "-avoid-version $ENV{LDFLAGS_FOR_BUILD}") ++ # endif() + + if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS) + # configure not using all flags to check if compiler works ... diff --git a/vcpkg-overlay/triplets/maa-android-library-override.cmake b/vcpkg-overlay/triplets/maa-android-library-override.cmake index fbbce54..4796fcd 100644 --- a/vcpkg-overlay/triplets/maa-android-library-override.cmake +++ b/vcpkg-overlay/triplets/maa-android-library-override.cmake @@ -3,3 +3,8 @@ if(PORT MATCHES "onnxruntime") string(APPEND VCPKG_C_FLAGS "-Wno-error=shorten-64-to-32") string(APPEND VCPKG_CXX_FLAGS "-Wno-error=shorten-64-to-32") endif() +if (PORT MATCHES "curl") + message("add -Wno-error=implicit-function-declaration for ${PORT}") + string(APPEND VCPKG_C_FLAGS "-Wno-error=implicit-function-declaration") + string(APPEND VCPKG_CXX_FLAGS "-Wno-error=implicit-function-declaration") +endif() diff --git a/vcpkg-overlay/triplets/maa-arm-android.cmake b/vcpkg-overlay/triplets/maa-arm-android.cmake new file mode 100644 index 0000000..4499b5f --- /dev/null +++ b/vcpkg-overlay/triplets/maa-arm-android.cmake @@ -0,0 +1,12 @@ +set(VCPKG_TARGET_ARCHITECTURE arm) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_CMAKE_SYSTEM_NAME Android) +set(VCPKG_CMAKE_SYSTEM_VERSION 23) +set(VCPKG_BUILD_TYPE release) +set(VCPKG_MAKE_BUILD_TRIPLET "--host=arm-linux-android") +set(VCPKG_TARGET_TRIPLET arm-android) +set(VCPKG_CMAKE_CONFIGURE_OPTIONS ${VCPKG_CMAKE_CONFIGURE_OPTIONS} -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF + -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-s") + +include(${CMAKE_CURRENT_LIST_DIR}/maa-linux-library-override.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/maa-android-library-override.cmake) diff --git a/vcpkg-overlay/triplets/maa-arm64-android.cmake b/vcpkg-overlay/triplets/maa-arm64-android.cmake index e3c368d..962d2bb 100644 --- a/vcpkg-overlay/triplets/maa-arm64-android.cmake +++ b/vcpkg-overlay/triplets/maa-arm64-android.cmake @@ -4,6 +4,7 @@ set(VCPKG_CMAKE_SYSTEM_NAME Android) set(VCPKG_CMAKE_SYSTEM_VERSION 23) set(VCPKG_BUILD_TYPE release) set(VCPKG_MAKE_BUILD_TRIPLET "--host=aarch64-linux-android") +set(VCPKG_TARGET_TRIPLET arm64-android) set(VCPKG_CMAKE_CONFIGURE_OPTIONS ${VCPKG_CMAKE_CONFIGURE_OPTIONS} -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-s") diff --git a/vcpkg-overlay/triplets/maa-x64-android.cmake b/vcpkg-overlay/triplets/maa-x64-android.cmake index b486868..487df73 100644 --- a/vcpkg-overlay/triplets/maa-x64-android.cmake +++ b/vcpkg-overlay/triplets/maa-x64-android.cmake @@ -4,6 +4,7 @@ set(VCPKG_CMAKE_SYSTEM_NAME Android) set(VCPKG_CMAKE_SYSTEM_VERSION 23) set(VCPKG_BUILD_TYPE release) set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86_64-linux-android") +set(VCPKG_TARGET_TRIPLET x64-android) set(VCPKG_CMAKE_CONFIGURE_OPTIONS ${VCPKG_CMAKE_CONFIGURE_OPTIONS} -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF) include(${CMAKE_CURRENT_LIST_DIR}/maa-linux-library-override.cmake) diff --git a/vcpkg-overlay/triplets/maa-x86-android.cmake b/vcpkg-overlay/triplets/maa-x86-android.cmake new file mode 100644 index 0000000..79f4902 --- /dev/null +++ b/vcpkg-overlay/triplets/maa-x86-android.cmake @@ -0,0 +1,11 @@ +set(VCPKG_TARGET_ARCHITECTURE x86) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_CMAKE_SYSTEM_NAME Android) +set(VCPKG_CMAKE_SYSTEM_VERSION 23) +set(VCPKG_BUILD_TYPE release) +set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86-linux-android") +set(VCPKG_TARGET_TRIPLET x86-android) +set(VCPKG_CMAKE_CONFIGURE_OPTIONS ${VCPKG_CMAKE_CONFIGURE_OPTIONS} -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF) + +include(${CMAKE_CURRENT_LIST_DIR}/maa-linux-library-override.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/maa-android-library-override.cmake)