Added scripts for build iOS monero dependencies

This commit is contained in:
M 2021-09-13 19:33:32 +03:00
parent 9d7e465211
commit b81f467986
11 changed files with 233 additions and 19 deletions

View file

@ -8,13 +8,14 @@
#include "thread" #include "thread"
#include "CwWalletListener.h" #include "CwWalletListener.h"
#if __APPLE__ #if __APPLE__
#include "../External/android/monero/include/wallet2_api.h" // Fix for randomx on ios
void __clear_cache(void* start, void* end) { }
#include "../External/ios/include/wallet2_api.h"
#else #else
#include "../External/android/x86/include/wallet2_api.h" #include "../External/android/x86/include/wallet2_api.h"
#endif #endif
using namespace std::chrono_literals; using namespace std::chrono_literals;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {

View file

@ -14,41 +14,41 @@ Pod::Spec.new do |s|
s.source_files = 'Classes/**/*' s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h, Classes/*.h, External/ios/libs/monero/include/src/**/*.h, External/ios/libs/monero/include/contrib/**/*.h, External/ios/libs/monero/include/External/ios/**/*.h' s.public_header_files = 'Classes/**/*.h, Classes/*.h, External/ios/libs/monero/include/src/**/*.h, External/ios/libs/monero/include/contrib/**/*.h, External/ios/libs/monero/include/External/ios/**/*.h'
s.dependency 'Flutter' s.dependency 'Flutter'
s.platform = :ios, '9.0' s.platform = :ios, '10.0'
s.swift_version = '4.0' s.swift_version = '4.0'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'arm64', 'ENABLE_BITCODE' => 'NO' } s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'arm64', 'ENABLE_BITCODE' => 'NO' }
s.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/Classes/*.h" } s.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/Classes/*.h" }
s.subspec 'OpenSSL' do |openssl| s.subspec 'OpenSSL' do |openssl|
openssl.preserve_paths = 'External/ios/libs/OpenSSL/include/openssl/*.h', 'External/ios/libs/OpenSSL/include/LICENSE' openssl.preserve_paths = 'External/ios/include/*.h'
openssl.vendored_libraries = 'External/ios/libs/OpenSSL/lib/libcrypto.a', 'External/ios/libs/OpenSSL/lib/libssl.a' openssl.vendored_libraries = 'External/ios/lib/libcrypto.a', 'External/ios/lib/libssl.a'
openssl.libraries = 'ssl', 'crypto' openssl.libraries = 'ssl', 'crypto'
openssl.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/OpenSSL/include/**" } openssl.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" }
end end
s.subspec 'Monero' do |monero| s.subspec 'Monero' do |monero|
monero.preserve_paths = 'External/ios/libs/monero/include/src/**/*.h', 'External/ios/libs/monero/include/External/ios/**/*.h', 'External/ios/libs/monero/include/contrib/**/*.h' monero.preserve_paths = 'External/ios/include/**/*.h'
monero.vendored_libraries = 'External/ios/libs/monero/libs/lib-ios/*.a' monero.vendored_libraries = 'External/ios/lib/libeasylogging.a', 'External/ios/lib/libepee.a', 'External/ios/lib/liblmdb.a', 'External/ios/lib/librandomx.a', 'External/ios/lib/libunbound.a', 'External/ios/lib/libwallet_merged.a', 'libcryptonote_basic.a', 'libcryptonote_format_utils_basic.a'
monero.libraries = 'easylogging', 'epee', 'unbound', 'wallet_merged', 'lmdb', 'randomx' monero.libraries = 'easylogging', 'epee', 'unbound', 'wallet_merged', 'lmdb', 'randomx', 'cryptonote_basic', 'cryptonote_format_utils_basic'
monero.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/monero/include/src/**" } monero.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include" }
end end
s.subspec 'Boost' do |boost| s.subspec 'Boost' do |boost|
boost.preserve_paths = 'External/ios/libs/boost/include/**/*.h', 'External/ios/libs/boost/include/**/*.h' boost.preserve_paths = 'External/ios/include/**/*.h', 'External/ios/include/**/*.h'
boost.vendored_libraries = 'External/ios/libs/boost/build/libs/universal/*.a' boost.vendored_libraries = 'External/ios/lib/libboost_chrono.a', 'External/ios/lib/libboost_date_time.a', 'External/ios/lib/libboost_filesystem.a', 'External/ios/lib/libboost_graph.a', 'External/ios/lib/libboost_locale.a', 'External/ios/lib/libboost_program_options.a', 'External/ios/lib/libboost_random.a', 'External/ios/lib/libboost_regex.a', 'External/ios/lib/libboost_serialization.a', 'External/ios/lib/libboost_system.a', 'External/ios/lib/libboost_thread.a', 'External/ios/lib/libboost_wserialization.a'
boost.libraries = 'boost', 'boost_wserialization', 'boost_thread', 'boost_system', 'boost_signals', 'boost_serialization', 'boost_regex', 'boost_random', 'boost_program_options', 'boost_locale', 'boost_graph', 'boost_filesystem', 'boost_date_time', 'boost_chrono' boost.libraries = 'boost_wserialization', 'boost_thread', 'boost_system', 'boost_serialization', 'boost_regex', 'boost_random', 'boost_program_options', 'boost_locale', 'boost_graph', 'boost_filesystem', 'boost_date_time', 'boost_chrono'
boost.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/boost/include/**" } boost.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" }
end end
s.subspec 'Sodium' do |sodium| s.subspec 'Sodium' do |sodium|
sodium.preserve_paths = 'External/ios/libs/sodium/include/**/*.h' sodium.preserve_paths = 'External/ios/include/**/*.h'
sodium.vendored_libraries = 'External/ios/libs/sodium/lib/libsodium.a' sodium.vendored_libraries = 'External/ios/lib/libsodium.a'
sodium.libraries = 'sodium' sodium.libraries = 'sodium'
sodium.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/sodium/include/**" } sodium.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" }
end end
s.subspec 'lmdb' do |lmdb| s.subspec 'lmdb' do |lmdb|
lmdb.vendored_libraries = 'External/ios/libs/lmdb/liblmdb.a' lmdb.vendored_libraries = 'External/ios/lib/liblmdb.a'
lmdb.libraries = 'lmdb' lmdb.libraries = 'lmdb'
end end
end end

View file

@ -165,7 +165,7 @@ SPEC CHECKSUMS:
BigInt: f668a80089607f521586bbe29513d708491ef2f7 BigInt: f668a80089607f521586bbe29513d708491ef2f7
connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467 connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467
CryptoSwift: 093499be1a94b0cae36e6c26b70870668cb56060 CryptoSwift: 093499be1a94b0cae36e6c26b70870668cb56060
cw_monero: 78f369253cc913efc23db9cf6be81a11eaf40fe1 cw_monero: c79d5530b828b8013c1db421f1be8bab687f7b7e
devicelocale: b22617f40038496deffba44747101255cee005b0 devicelocale: b22617f40038496deffba44747101255cee005b0
DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179

9
scripts/ios/build_all.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
. ./config.sh
./install_missing_headers.sh
./build_openssl.sh
./build_boost.sh
./build_sodium.sh
./build_zmq.sh
./build_monero.sh

23
scripts/ios/build_boost.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/sh
. ./config.sh
MIN_IOS_VERSION=10.0
BOOST_URL="https://github.com/cake-tech/Apple-Boost-BuildScript.git"
BOOST_DIR_PATH="${EXTERNAL_IOS_SOURCE_DIR}/Apple-Boost-BuildScript"
BOOST_VERSION=1.74.0
BOOST_LIBS="random regex graph random chrono thread filesystem system date_time locale serialization program_options"
echo "============================ Boost ============================"
echo "Cloning Apple-Boost-BuildScript from - $BOOST_URL"
git clone -b build $BOOST_URL $BOOST_DIR_PATH
cd $BOOST_DIR_PATH
./boost.sh -ios \
--min-ios-version ${MIN_IOS_VERSION} \
--boost-libs "${BOOST_LIBS}" \
--boost-version ${BOOST_VERSION} \
--no-framework
mv ${BOOST_DIR_PATH}/build/boost/${BOOST_VERSION}/ios/release/prefix/include/* $EXTERNAL_IOS_INCLUDE_DIR
mv ${BOOST_DIR_PATH}/build/boost/${BOOST_VERSION}/ios/release/prefix/lib/* $EXTERNAL_IOS_LIB_DIR

61
scripts/ios/build_monero.sh Executable file
View file

@ -0,0 +1,61 @@
#!/bin/sh
. ./config.sh
MONERO_URL="https://github.com/monero-project/monero.git"
MONERO_DIR_PATH="${EXTERNAL_IOS_SOURCE_DIR}/monero"
MONERO_VERSION=tags/v0.17.2.3
BUILD_TYPE=release
PREFIX=${EXTERNAL_IOS_DIR}
echo "Cloning monero from - $MONERO_URL to - $MONERO_DIR_PATH"
git clone $MONERO_URL $MONERO_DIR_PATH
cd $MONERO_DIR_PATH
git checkout $MONERO_VERSION
git submodule update --init --force
mkdir -p build
cd ..
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -z $INSTALL_PREFIX ]; then
INSTALL_PREFIX=${ROOT_DIR}/monero
fi
for arch in "arm64" #"armv7" "arm64"
do
echo "Building IOS ${arch}"
export CMAKE_INCLUDE_PATH="${PREFIX}/include"
export CMAKE_LIBRARY_PATH="${PREFIX}/lib"
case $arch in
"armv7" )
DEST_LIB=../../lib-armv7;;
"arm64" )
DEST_LIB=../../lib-armv8-a;;
esac
rm -r monero/build > /dev/null
mkdir -p monero/build/${BUILD_TYPE}
pushd monero/build/${BUILD_TYPE}
cmake -D IOS=ON \
-DARCH=${arch} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DSTATIC=ON \
-DBUILD_GUI_DEPS=ON \
-DINSTALL_VENDORED_LIBUNBOUND=ON \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DUSE_DEVICE_TREZOR=OFF \
../..
make -j4 && make install
cp external/randomx/librandomx.a ${DEST_LIB}
cp src/cryptonote_basic/libcryptonote_basic.a ${DEST_LIB}
cp src/cryptonote_basic/libcryptonote_format_utils_basic.a ${DEST_LIB}
popd
done
#only for arm64
cp ${MONERO_DIR_PATH}/lib-armv8-a/* $EXTERNAL_IOS_LIB_DIR
cp ${MONERO_DIR_PATH}/include/wallet/api/* $EXTERNAL_IOS_INCLUDE_DIR

16
scripts/ios/build_openssl.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
. ./config.sh
OPEN_SSL_URL="https://github.com/x2on/OpenSSL-for-iPhone.git"
OPEN_SSL_DIR_PATH="${EXTERNAL_IOS_SOURCE_DIR}/OpenSSL"
echo "============================ OpenSSL ============================"
echo "Cloning Open SSL from - $OPEN_SSL_URL"
git clone $OPEN_SSL_URL $OPEN_SSL_DIR_PATH
cd $OPEN_SSL_DIR_PATH
./build-libssl.sh --version=1.1.1k --archs="x86_64 arm64 armv7s armv7" --targets="ios64-cross-arm64" --deprecated
mv ${OPEN_SSL_DIR_PATH}/include/* $EXTERNAL_IOS_INCLUDE_DIR
mv ${OPEN_SSL_DIR_PATH}/lib/* $EXTERNAL_IOS_LIB_DIR

16
scripts/ios/build_sodium.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
. ./config.sh
SODIUM_PATH="${EXTERNAL_IOS_SOURCE_DIR}/libsodium"
SODIUM_URL="https://github.com/jedisct1/libsodium.git"
echo "============================ SODIUM ============================"
echo "Cloning SODIUM from - $SODIUM_URL"
git clone $SODIUM_URL $SODIUM_PATH --branch stable
cd $SODIUM_PATH
./dist-build/ios.sh
mv ${SODIUM_PATH}/libsodium-ios/include/* $EXTERNAL_IOS_INCLUDE_DIR
mv ${SODIUM_PATH}/libsodium-ios/lib/* $EXTERNAL_IOS_LIB_DIR

13
scripts/ios/build_zmq.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
. ./config.sh
ZMQ_PATH="${EXTERNAL_IOS_SOURCE_DIR}/libzmq"
ZMQ_URL="https://github.com/zeromq/libzmq.git"
echo "============================ ZMQ ============================"
echo "Cloning ZMQ from - $ZMQ_URL"
git clone $ZMQ_URL $ZMQ_PATH
cp ${ZMQ_PATH}/include/* $EXTERNAL_IOS_INCLUDE_DIR

12
scripts/ios/config.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
export IOS_SCRIPTS_DIR=`pwd`
export CW_ROOT=${IOS_SCRIPTS_DIR}/../..
export EXTERNAL_DIR=${CW_ROOT}/cw_monero/ios/External
export EXTERNAL_IOS_DIR=${EXTERNAL_DIR}/ios
export EXTERNAL_IOS_SOURCE_DIR=${EXTERNAL_IOS_DIR}/sources
export EXTERNAL_IOS_LIB_DIR=${EXTERNAL_IOS_DIR}/lib
export EXTERNAL_IOS_INCLUDE_DIR=${EXTERNAL_IOS_DIR}/include
mkdir -p $EXTERNAL_IOS_LIB_DIR
mkdir -p $EXTERNAL_IOS_INCLUDE_DIR

View file

@ -0,0 +1,63 @@
#!/bin/bash
. ./config.sh
echo "Installing missing headers"
# vmmeter
mkdir -p ${EXTERNAL_IOS_INCLUDE_DIR}/sys
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/sys/vmmeter.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/vmmeter.h ${EXTERNAL_IOS_INCLUDE_DIR}/sys/vmmeter.h
fi
# netinet
mkdir -p ${EXTERNAL_IOS_INCLUDE_DIR}/netinet
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/netinet/ip_var.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/netinet/ip_var.h ${EXTERNAL_IOS_INCLUDE_DIR}/netinet/ip_var.h
fi
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/netinet/udp_var.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/netinet/udp_var.h ${EXTERNAL_IOS_INCLUDE_DIR}/netinet/udp_var.h
fi
# IOKit
mkdir -p ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOTypes.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/IOTypes.h ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOTypes.h
fi
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOKitLib.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/IOKitLib.h ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOKitLib.h
fi
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOReturn.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/IOReturn.h ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOReturn.h
fi
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/OSMessageNotification.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/OSMessageNotification.h ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/OSMessageNotification.h
fi
# IOKit/ps
mkdir -p ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/ps
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/ps/IOPSKeys.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/ps/IOPSKeys.h ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/ps/IOPSKeys.h
fi
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/ps/IOPowerSources.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/ps/IOPowerSources.h ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/ps/IOPowerSources.h
fi
# libkern
mkdir -p ${EXTERNAL_IOS_INCLUDE_DIR}/libkern
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/libkern/OSTypes.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libkern/OSTypes.h ${EXTERNAL_IOS_INCLUDE_DIR}/libkern/OSTypes.h
fi
if [ ! -f ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOKitKeys.h ]; then
cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/IOKitKeys.h ${EXTERNAL_IOS_INCLUDE_DIR}/IOKit/IOKitKeys.h
fi