From bf2ff45282059ee64c893889e13aa7229cf8fb89 Mon Sep 17 00:00:00 2001 From: m Date: Wed, 15 May 2024 20:35:21 +0100 Subject: [PATCH] Add ability to build monero wallet lib as universal lib. Update macOS build guide. Change default arch for macOS project to . --- howto-build-macos.md | 9 +++++++ macos/Runner.xcodeproj/project.pbxproj | 6 ++--- scripts/macos/build_monero_all.sh | 35 ++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/howto-build-macos.md b/howto-build-macos.md index c8cc5bf52..08ecf01f0 100644 --- a/howto-build-macos.md +++ b/howto-build-macos.md @@ -74,6 +74,15 @@ Build the Monero libraries and their dependencies: `$ ./build_monero_all.sh` +If you be needed to build universal monero lib, then it will require additional steps. Steps for build universal monero lib on mac with Apple Silicon (arm64): + +- Need to install Rosetta: `$ softwareupdate --install-rosetta` +- Need to install [Brew](https://brew.sh/) with rosetta: `$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` (or take another way to install brew, but be use that you have installed it into /usr/local as it's using for x86_64 macs) +- Install dependencies for build monero wallet lib for x86_64 with brew: `$ arch -x86_64 /usr/local/bin/brew install unbound boost@1.76 zmq` and link installed boost@1.76 for x86_64 `$ arch -x86_64 /usr/local/bin/brew link boost@1.76` +- Run building script with additional argument: `$ ./build_monero_all.sh universal` + +If you will be needed to build monero wallet lib only for x86_64 on arm64 mac, then you need use steps above, but run build script with rosetta without arguments: `$ arch -x86_64 ./build_monero_all.sh`. + It is now time to change back to the base directory of the CakeWallet source code: `$ cd ../../` diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 85f53d16a..60150f4eb 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -437,7 +437,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = arm64; + ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; @@ -572,7 +572,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = arm64; + ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; @@ -601,7 +601,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = arm64; + ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; diff --git a/scripts/macos/build_monero_all.sh b/scripts/macos/build_monero_all.sh index ae9c8889b..0fb0fa8b6 100755 --- a/scripts/macos/build_monero_all.sh +++ b/scripts/macos/build_monero_all.sh @@ -4,6 +4,8 @@ set -x -e cd "$(dirname "$0")" NPROC="-j$(sysctl -n hw.logicalcpu)" +LIBS="" +MONEROC_RELEASE_DIR="../monero_c/release/monero" ../prepare_moneroc.sh @@ -18,13 +20,36 @@ then popd done else + if [[ "x$1" == "xuniversal" ]]; then + ARCHS=(arm64 x86_64) + else + ARCHS=$(uname -m) + fi for COIN in monero; do - pushd ../monero_c - ./build_single.sh ${COIN} host-apple-darwin $NPROC - popd + for ARCH in "${ARCHS[@]}"; + do + if [[ "$ARCH" == "arm64" ]]; then + export HOMEBREW_PREFIX=/opt/homebrew + HOST="aarch64-host-apple-darwin" + else + export HOMEBREW_PREFIX=/usr/local + HOST="${ARCH}-host-apple-darwin" + fi + + LIBS="${LIBS} -arch ${ARCH} ${MONEROC_RELEASE_DIR}/${HOST}_libwallet2_api_c.dylib" + + if [[ ! $(uname -m) == $ARCH ]]; then + PRC="arch -${ARCH}" + fi + + pushd ../monero_c + $PRC ./build_single.sh ${COIN} ${HOST} $NPROC + unxz -f ./release/monero/${HOST}_libwallet2_api_c.dylib.xz + + popd + done done fi -unxz -f ../monero_c/release/monero/host-apple-darwin_libwallet2_api_c.dylib.xz -# unxz -f ../monero_c/release/wownero/host-apple-darwin_libwallet2_api_c.dylib.xz +lipo -create ${LIBS} -output "${MONEROC_RELEASE_DIR}/host-apple-darwin_libwallet2_api_c.dylib"