Skip to content

Commit

Permalink
fix: try to fix android arch (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO authored Dec 23, 2023
1 parent 8e8dc2e commit bb5ff57
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: build

on:
push:
tags: "*"
workflow_dispatch:
inputs:
use-cache:
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
21 changes: 21 additions & 0 deletions vcpkg-overlay/scripts/remove_avoid-version.patch
Original file line number Diff line number Diff line change
@@ -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 ...
5 changes: 5 additions & 0 deletions vcpkg-overlay/triplets/maa-android-library-override.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 12 additions & 0 deletions vcpkg-overlay/triplets/maa-arm-android.cmake
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions vcpkg-overlay/triplets/maa-arm64-android.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
1 change: 1 addition & 0 deletions vcpkg-overlay/triplets/maa-x64-android.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions vcpkg-overlay/triplets/maa-x86-android.cmake
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit bb5ff57

Please sign in to comment.