add support for ios simulator (#111)

* add support for ios simulator

* remove libmd.tbd dependency
This commit is contained in:
cyan
2025-02-04 18:22:07 +01:00
committed by GitHub
parent 127c54599c
commit 9301097ff5
15 changed files with 79 additions and 17 deletions

View File

@@ -289,9 +289,14 @@ jobs:
path: |
contrib/depends/built/*
key: depends-${{ github.job }}-${{ hashFiles('contrib/depends/packages/*.mk') }}
- name: build
- name: build (aarch64-apple-ios)
run: |
./build_single.sh ${{ matrix.coin }} aarch64-apple-ios -j$(sysctl -n hw.logicalcpu)
- name: build (aarch64-apple-iossimulator)
run: |
./build_single.sh ${{ matrix.coin }} aarch64-apple-iossimulator -j$(sysctl -n hw.logicalcpu)
- name: rename artifacts
run: |
mkdir release/gh/

View File

@@ -88,23 +88,23 @@ pushd release/$repo
# cp ../../$repo/build/${HOST_ABI}/external/polyseed/libpolyseed.${APPENDIX} ${HOST_ABI}_libpolyseed.${APPENDIX}
# rm ${HOST_ABI}_libpolyseed.${APPENDIX}.xz || true
# xz -e ${HOST_ABI}_libpolyseed.${APPENDIX}
elif [[ "${HOST_ABI}" == "x86_64-apple-darwin11" || "${HOST_ABI}" == "aarch64-apple-darwin11" || "${HOST_ABI}" == "host-apple-darwin" || "${HOST_ABI}" == "x86_64-host-apple-darwin" || "${HOST_ABI}" == "aarch64-apple-darwin" || "${HOST_ABI}" == "x86_64-apple-darwin" || "${HOST_ABI}" == "host-apple-ios" || "${HOST_ABI}" == "aarch64-apple-ios" ]];
elif [[ "${HOST_ABI}" == "x86_64-apple-darwin11" || "${HOST_ABI}" == "aarch64-apple-darwin11" || "${HOST_ABI}" == "host-apple-darwin" || "${HOST_ABI}" == "x86_64-host-apple-darwin" || "${HOST_ABI}" == "aarch64-apple-darwin" || "${HOST_ABI}" == "x86_64-apple-darwin" || "${HOST_ABI}" == "host-apple-ios" || "${HOST_ABI}" == "aarch64-apple-ios" || "${HOST_ABI}" == "aarch64-apple-iossimulator" ]];
then
APPENDIX="${APPENDIX}dylib"
else
APPENDIX="${APPENDIX}so"
fi
xz -e ../../${repo}_libwallet2_api_c/build/${HOST_ABI}/libwallet2_api_c.${APPENDIX}
xz -ek ../../${repo}_libwallet2_api_c/build/${HOST_ABI}/libwallet2_api_c.${APPENDIX}
mv ../../${repo}_libwallet2_api_c/build/${HOST_ABI}/libwallet2_api_c.${APPENDIX}.xz ${HOST_ABI}_libwallet2_api_c.${APPENDIX}.xz
# Extra libraries
if [[ "$HOST_ABI" == "x86_64-w64-mingw32" || "$HOST_ABI" == "i686-w64-mingw32" ]];
then
cp /usr/${HOST_ABI}/lib/libwinpthread-1.dll ${HOST_ABI}_libwinpthread-1.dll
rm ${HOST_ABI}_libwinpthread-1.dll.xz || true
xz -e ${HOST_ABI}_libwinpthread-1.dll
xz -ek ${HOST_ABI}_libwinpthread-1.dll
####
cp /usr/lib/gcc/${HOST_ABI}/*-posix/libssp-0.dll ${HOST_ABI}_libssp-0.dll
rm ${HOST_ABI}_libssp-0.dll.xz || true
xz -e ${HOST_ABI}_libssp-0.dll
xz -ek ${HOST_ABI}_libssp-0.dll
fi
popd

View File

@@ -91,6 +91,9 @@ endif
ifeq ($(host_os),ios)
host_cmake=iOS
endif
ifeq ($(host_os),iossimulator)
host_cmake=iOS
endif
ifeq ($(host_os),android)
host_cmake=Android
endif

View File

@@ -1,6 +1,5 @@
IOS_MIN_VERSION=12.0
IOS_SDK=$(shell xcrun --sdk iphoneos --show-sdk-path)
IOS_SIMULATOR_SDK=$(shell xcrun --sdk iphonesimulator --show-sdk-path)
ifeq (aarch64, $(host_arch))
CC_target_ios=arm64-apple-ios

View File

@@ -0,0 +1,26 @@
IOS_MIN_VERSION=12.0
IOS_SDK=$(shell xcrun --sdk iphonesimulator --show-sdk-path)
ifeq (aarch64, $(host_arch))
CC_target_iossimulator=arm64-apple-ios-simulator
iossimulator_host=arm64-apple-darwin
aarch64_iossimulator_host=arm64-apple-darwin
else
CC_target_iossimulator=x86_64-apple-ios-simulator
iossimulator_host=x86_64-apple-darwin
x86_64_iossimulator_host=x86_64-apple-darwin
endif
iossimulator_CC=$(shell xcrun -f clang) -target $(CC_target_iossimulator) -mios-version-min=$(IOS_MIN_VERSION) --sysroot $(IOS_SDK)
iossimulator_CXX=$(shell xcrun -f clang++) -target $(CC_target_iossimulator) -mios-version-min=$(IOS_MIN_VERSION) --sysroot $(IOS_SDK) -stdlib=libc++ -std=c++14
iossimulator_AR:=$(shell xcrun -f ar)
iossimulator_RANLIB:=$(shell xcrun -f ranlib)
iossimulator_STRIP:=$(shell xcrun -f strip)
iossimulator_LIBTOOL:=$(shell xcrun -f libtool)
iossimulator_OTOOL:=$(shell xcrun -f otool)
iossimulator_NM:=$(shell xcrun -f nm)
iossimulator_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
iossimulator_native_toolchain=
iossimulator_CFLAGS=-pipe
iossimulator_CXXFLAGS=$(iossimulator_CFLAGS)

View File

@@ -16,6 +16,7 @@ $(package)_config_opts_linux=threadapi=pthread runtime-link=static
$(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android
$(package)_config_opts_darwin=--toolset=darwin runtime-link=static
$(package)_config_opts_ios=--toolset=darwin-$($(package)_ios_COMPILER_VERSION)~iphone runtime-link=static
$(package)_config_opts_iossimulator=--toolset=darwin-$($(package)_ios_COMPILER_VERSION)~iphone runtime-link=static
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
$(package)_config_opts_x86_64_mingw32=address-model=64
$(package)_config_opts_i686_mingw32=address-model=32
@@ -24,12 +25,15 @@ $(package)_toolset_$(host_os)=gcc
$(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_archiver_darwin=$($(package)_libtool)
$(package)_archiver_ios=$($(package)_libtool)
$(package)_archiver_iossimulator=$($(package)_libtool)
$(package)_toolset_darwin=darwin
$(package)_toolset_ios=darwin
$(package)_toolset_iossimulator=darwin
$(package)_toolset_android=gcc
$(package)_toolset_mingw32=gcc
$(package)_toolset2_$(host_os)=
$(package)_toolset2_ios=$($(package)_ios_COMPILER_VERSION)~iphone
$(package)_toolset2_iossimulator=$($(package)_ios_COMPILER_VERSION)~iphone
$(package)_config_libraries=system,filesystem,thread,timer,date_time,chrono,regex,serialization,atomic,program_options,locale,log
$(package)_cxxflags_linux=-fPIC
$(package)_cxxflags_freebsd=-fPIC
@@ -37,6 +41,7 @@ $(package)_cxxflags_android=-fPIC
$(package)_cxxflags_darwin=-fPIC -std=c++11
$(package)_ldflags_darwin=-L$(host_prefix)/lib -L$(shell xcrun --sdk macosx --show-sdk-path)/usr/lib
$(package)_ldflags_ios=-L$(host_prefix)/lib -L$(IOS_SDK)/usr/lib
$(package)_ldflags_iossimulator=-L$(host_prefix)/lib -L$(IOS_SDK)/usr/lib
endef
define $(package)_preprocess_cmds

View File

@@ -11,6 +11,7 @@ define $(package)_set_vars
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_freebsd=--with-pic
$(package)_ar_ios=$($(package)_ar)
$(package)_ar_iossimulator=$($(package)_ar)
endef
define $(package)_preprocess_cmds

View File

@@ -10,6 +10,15 @@ define $(package)_set_vars
$(package)_config_opts_linux=--with-pic
endef
define $(package)_preprocess_cmds
cp -f $(BASEDIR)/config.guess config.guess &&\
cp -f $(BASEDIR)/config.sub config.sub &&\
cp -f $(BASEDIR)/config.guess third_party/googletest/googletest/build-aux/config.guess &&\
cp -f $(BASEDIR)/config.sub third_party/googletest/googletest/build-aux/config.sub &&\
cp -f $(BASEDIR)/config.guess third_party/googletest/googlemock/build-aux/config.guess &&\
cp -f $(BASEDIR)/config.sub third_party/googletest/googlemock/build-aux/config.sub
endef
define $(package)_config_cmds
$($(package)_autoconf)
endef

View File

@@ -38,6 +38,9 @@ $(package)_config_opts_armv7a_android=--static android-arm
$(package)_config_opts_aarch64_android=--static android-arm64
$(package)_config_opts_aarch64_darwin=darwin64-arm64-cc
$(package)_config_opts_aarch64_ios=darwin64-arm64-cc
$(package)_config_opts_aarch64_iossimulator=darwin64-arm64-cc
$(package)_config_opts_x86_64_ios=darwin64-x86_64-cc
$(package)_config_opts_x86_64_iossimulator=darwin64-x86_64-cc
$(package)_config_opts_riscv64_linux=linux-generic64
$(package)_config_opts_mipsel_linux=linux-generic32
$(package)_config_opts_mips_linux=linux-generic32

View File

@@ -14,6 +14,7 @@ android_packages = ncurses readline sodium
darwin_native_packages = $(hardware_native_packages)
darwin_packages = ncurses readline sodium $(hardware_packages)
ios_packages = sodium protobuf native_protobuf
iossimulator_packages = sodium protobuf native_protobuf
# not really native...
freebsd_native_packages = freebsd_base

View File

@@ -14,7 +14,13 @@ define $(package)_set_vars
endef
define $(package)_preprocess_cmds
patch -p0 < $($(package)_patch_dir)/visibility.patch
patch -p0 < $($(package)_patch_dir)/visibility.patch && \
cp -f $(BASEDIR)/config.guess config.guess &&\
cp -f $(BASEDIR)/config.sub config.sub &&\
cp -f $(BASEDIR)/config.guess third_party/googletest/googletest/build-aux/config.guess &&\
cp -f $(BASEDIR)/config.sub third_party/googletest/googletest/build-aux/config.sub &&\
cp -f $(BASEDIR)/config.guess third_party/googletest/googlemock/build-aux/config.guess &&\
cp -f $(BASEDIR)/config.sub third_party/googletest/googlemock/build-aux/config.sub
endef
define $(package)_config_cmds

View File

@@ -6,14 +6,16 @@ $(package)_sha256_hash=6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e
$(package)_patches=disable-glibc-getrandom-getentropy.patch fix-whitespace.patch
define $(package)_set_vars
$(package)_config_env_android=ANDROID_NDK_ROOT="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
$(package)_config_env_android=ANDROID_NDK_ROOT="$(host_prefix)/native" PATH="${PATH}:$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
$(package)_config_opts=--enable-static --disable-shared --with-pic
$(package)_config_opts+=--prefix=$(host_prefix)
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/disable-glibc-getrandom-getentropy.patch &&\
patch -p1 < $($(package)_patch_dir)/fix-whitespace.patch
patch -p1 < $($(package)_patch_dir)/fix-whitespace.patch &&\
cp -f $(BASEDIR)/config.guess build-aux/config.guess &&\
cp -f $(BASEDIR)/config.sub build-aux/config.sub
endef
define $(package)_config_cmds

View File

@@ -6,12 +6,12 @@ $(package)_sha256_hash=90337653d92d4a13de590781371c604f9031cdb50520366aa1e3a91e1
$(package)_patches=fix_obj_order.patch
define $(package)_preprocess_cmds
patch -p0 < $($(package)_patch_dir)/fix_obj_order.patch
patch -p0 < $($(package)_patch_dir)/fix_obj_order.patch &&\
cp -f $(BASEDIR)/config.guess config/config.guess &&\
cp -f $(BASEDIR)/config.sub config/config.sub
endef
define $(package)_config_cmds
cp -f $(BASEDIR)/config.guess config/config.guess &&\
cp -f $(BASEDIR)/config.sub config/config.sub &&\
$($(package)_autoconf) --disable-shared --enable-static --disable-tests --disable-documentation AR_FLAGS=$($(package)_arflags)
endef

View File

@@ -10,6 +10,7 @@ define $(package)_set_vars
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_freebsd=--with-pic
$(package)_config_opts_ios=--host=$(host_arch)-apple-darwin
$(package)_config_opts_iossimulator=--host=$(host_arch)-apple-darwin
$(package)_cxxflags=-std=c++11
$(package)_cxxflags_darwin=-std=c++11
$(package)_cxxflags_ios=-std=c++11

View File

@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5)
project(wallet2_api_c)
message(STATUS ABI_INFO = ${HOST_ABI})
set(MD_LIBRARY "")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
@@ -65,7 +67,7 @@ elseif(${HOST_ABI} STREQUAL "host-apple-darwin" OR
${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR
${HOST_ABI} STREQUAL "aarch64-host-apple-darwin")
set(EXTRA_LIBS_APPLE "-framework IOKit" "-framework CoreFoundation" "-framework Cocoa" apple_nghttp2)
elseif(${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios" OR ${HOST_ABI} STREQUAL "arm64-apple-ios")
elseif(${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios" OR ${HOST_ABI} STREQUAL "arm64-apple-ios" OR ${HOST_ABI} STREQUAL "arm64-apple-iossimulator" OR ${HOST_ABI} STREQUAL "x86_64-apple-iossimulator")
set(EXTRA_LIBS_APPLE "-framework IOKit" "-framework CoreFoundation" iconv )
endif()
@@ -73,7 +75,7 @@ if(${HOST_ABI} STREQUAL "x86_64-w64-mingw32" OR ${HOST_ABI} STREQUAL "i686-w64-m
target_link_options(wallet2_api_c PRIVATE -static-libgcc -static-libstdc++)
endif()
if(${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" OR ${HOST_ABI} STREQUAL "host-apple-darwin" OR ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios")
if(${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" OR ${HOST_ABI} STREQUAL "host-apple-darwin" OR ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios" OR ${HOST_ABI} STREQUAL "arm64-apple-iossimulator" OR ${HOST_ABI} STREQUAL "x86_64-apple-iossimulator")
set_target_properties(wallet2_api_c PROPERTIES SUFFIX ".dylib")
set_target_properties(wallet2_api_c PROPERTIES NO_SONAME 1)
@@ -88,7 +90,7 @@ elseif(${MONERO_FLAVOR} STREQUAL "zano")
target_compile_definitions(wallet2_api_c PRIVATE FLAVOR_ZANO)
endif()
if(NOT ${HOST_ABI} STREQUAL "x86_64-apple-darwin11" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "x86_64-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "host-apple-ios" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-ios")
if(NOT ${HOST_ABI} STREQUAL "x86_64-apple-darwin11" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "x86_64-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "host-apple-ios" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-ios" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-iossimulator" AND NOT ${HOST_ABI} STREQUAL "x86_64-apple-iossimulator")
set_target_properties(wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL")
endif()
@@ -99,8 +101,7 @@ if (${MONERO_FLAVOR} STREQUAL "zano")
endif()
add_subdirectory("${CMAKE_SOURCE_DIR}/../${MONERO_FLAVOR}" ${CMAKE_BINARY_DIR}/${MONERO_FLAVOR}_build EXCLUDE_FROM_ALL)
if(${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" OR ${HOST_ABI} STREQUAL "x86_64-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-darwin" OR ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios")
if(${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" OR ${HOST_ABI} STREQUAL "x86_64-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-darwin" OR ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-iossimulator" OR ${HOST_ABI} STREQUAL "x86_64-apple-iossimulator")
if (${MONERO_FLAVOR} STREQUAL "monero")
set(EXPORTED_SYMBOLS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/monero_libwallet2_api_c.exp)
elseif(${MONERO_FLAVOR} STREQUAL "wownero")