From 8f40508857d98de0b3d60bbb9e32ab583d50c083 Mon Sep 17 00:00:00 2001 From: preland Date: Wed, 24 Jul 2024 19:26:42 -0400 Subject: [PATCH 1/6] add build pipeline for cross-compiled macOS universal --- macos_universal/arm/CMakeLists.txt | 590 ++++++++++++++++++ macos_universal/arm/build.sh | 2 + macos_universal/arm/clean.sh | 2 + macos_universal/arm/cmake | 1 + macos_universal/arm/root | 1 + macos_universal/build.sh | 2 + macos_universal/universal/.combine.sh.swp | Bin 0 -> 12288 bytes macos_universal/universal/combine.sh | 2 + .../universal/combine_and_build_all.sh | 8 + macos_universal/x86/CMakeLists.txt | 590 ++++++++++++++++++ macos_universal/x86/build.sh | 2 + macos_universal/x86/clean.sh | 2 + macos_universal/x86/cmake | 1 + macos_universal/x86/root | 1 + 14 files changed, 1204 insertions(+) create mode 100644 macos_universal/arm/CMakeLists.txt create mode 100755 macos_universal/arm/build.sh create mode 100755 macos_universal/arm/clean.sh create mode 120000 macos_universal/arm/cmake create mode 120000 macos_universal/arm/root create mode 100755 macos_universal/build.sh create mode 100644 macos_universal/universal/.combine.sh.swp create mode 100755 macos_universal/universal/combine.sh create mode 100755 macos_universal/universal/combine_and_build_all.sh create mode 100644 macos_universal/x86/CMakeLists.txt create mode 100755 macos_universal/x86/build.sh create mode 100755 macos_universal/x86/clean.sh create mode 120000 macos_universal/x86/cmake create mode 120000 macos_universal/x86/root diff --git a/macos_universal/arm/CMakeLists.txt b/macos_universal/arm/CMakeLists.txt new file mode 100644 index 00000000..4ad96b30 --- /dev/null +++ b/macos_universal/arm/CMakeLists.txt @@ -0,0 +1,590 @@ +list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +cmake_minimum_required(VERSION 3.4.1) + + +#SET(CMAKE_C_COMPILER /path/to/c/compiler) +#SET(CMAKE_CXX_COMPILER /path/to/cpp/compiler) +#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") +#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++14 -F/Library/Frameworks -pthread -fsanitize=address") # TODO: way to enable sanitize? get runtime error with this on + +project(MoneroCppLibrary) + +set(BUILD_LIBRARY ON) +set(BUILD_SAMPLE OFF) +set(BUILD_SCRATCHPAD OFF) +set(BUILD_TESTS OFF) + +set(ROOT_DIR "${CMAKE_SOURCE_DIR}/../..") +################### +# monero-project +################### + +set(MONERO_PROJECT "${ROOT_DIR}/external/monero-project" CACHE STRING "Monero project source directory") +set(MONERO_PROJECT_SRC "${MONERO_PROJECT}/src") + +set(EXTERNAL_LIBS_DIR ${ROOT_DIR}/external-libs) +message(STATUS EXTERNAL_LIBS_DIR : ${EXTERNAL_LIBS_DIR}) + +################## +# Extra Flags +################## +if (WIN32) + add_definitions( "-D_GLIBCXX_USE_NANOSLEEP=1" ) # "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8 + add_definitions( "-DWIN32_LEAN_AND_MEAN" ) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -O2 -fPIC -std=c++14 -F/Library/Frameworks -pthread -lcrypto -lcrypt32") +else() + set(FRAMEWORK_DIR "${MONERO_PROJECT}/contrib/depends/aarch64-apple-darwin11/native/SDK/System/Library/Frameworks") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++14 -F${FRAMEWORK_DIR} -pthread") +endif() + +#################### +# Extra libraries +#################### + +if (APPLE) + if (DEPENDS) + list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework IOKit -framework AppKit") + else() + find_library(COREFOUNDATION CoreFoundation) + find_library(IOKIT IOKit) + find_library(APPKIT AppKit) + list(APPEND EXTRA_LIBRARIES ${IOKIT}) + list(APPEND EXTRA_LIBRARIES ${COREFOUNDATION}) + list(APPEND EXTRA_LIBRARIES ${APPKIT}) + endif() +endif() +if (WIN32) + list(APPEND EXTRA_LIBRARIES setupapi) +endif() + +message(STATUS EXTRA_LIBRARIES: ${EXTRA_LIBRARIES}) + +############ +# Protobuf +############ + +if (NOT APPLE) + include(FindProtobuf) + find_package(Protobuf) + message(STATUS "Protobuf lib: ${Protobuf_LIBRARY}, inc: ${Protobuf_INCLUDE_DIR}, protoc: ${Protobuf_PROTOC_EXECUTABLE}") +endif() + +############ +# LibUSB +############ + +find_library(usb_LIBRARY NAMES usb-1.0 libusb usb) +set(LibUSB_LIBRARIES ${usb_LIBRARY}) + +############ +# Boost +############ + +set(Boost_NO_BOOST_CMAKE 1) +set(Boost_USE_MULTITHREADED ON) +find_package(Boost 1.58 QUIET REQUIRED COMPONENTS chrono date_time filesystem program_options regex serialization wserialization system thread) +message(STATUS "Using Boost include dir at ${Boost_INCLUDE_DIR}") + +############ +# OpenSSL +############ + +if (APPLE AND NOT IOS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++14") + if (NOT OPENSSL_ROOT_DIR) + EXECUTE_PROCESS(COMMAND brew --prefix openssl + OUTPUT_VARIABLE OPENSSL_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Using OpenSSL found at ${OPENSSL_ROOT_DIR}") + endif() +endif() + +find_package(OpenSSL REQUIRED) +message(STATUS "Using OpenSSL include dir at ${OPENSSL_INCLUDE_DIR}") + +if(STATIC AND NOT IOS) + if(UNIX) + set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES};${CMAKE_DL_LIBS};${CMAKE_THREAD_LIBS_INIT}") + endif() +endif() + +if (WIN32) + list(APPEND OPENSSL_LIBRARIES ws2_32 crypt32) +endif() + +############ +# libsodium +############ + +find_library(SODIUM_LIBRARY sodium REQUIRED) +message(STATUS "Using libsodium library at ${SODIUM_LIBRARY}") + +############ +# HIDAPI +############ + +if(APPLE) + include_directories(SYSTEM /usr/include/malloc) + if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) + endif() +endif() +find_package(HIDAPI REQUIRED) +message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}") +add_definitions(-DHAVE_HIDAPI) + +############# +# Monero +############# + +set(MONERO_PROJECT_BUILD "${MONERO_PROJECT}/build/aarch64-apple-darwin11/release" CACHE STRING "Monero project build directory") + +message(STATUS "Using monero-project build: " ${MONERO_PROJECT_BUILD}) + +list(APPEND CMAKE_MODULE_PATH "${MONERO_PROJECT}/cmake") + +add_library(wallet STATIC IMPORTED) +set_target_properties(wallet PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/lib/libwallet.a) + +# libwallet-crypto.a provides x86_64 asm for some wallet functions +if (EXISTS ${MONERO_PROJECT_BUILD}/src/crypto/wallet/libwallet-crypto.a) + add_library(wallet_crypto_lib STATIC IMPORTED) + set_target_properties(wallet_crypto_lib PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/crypto/wallet/libwallet-crypto.a) + set(wallet_crypto wallet_crypto_lib) +endif() + +add_library(lmdb STATIC IMPORTED) +set_target_properties(lmdb PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/external/db_drivers/liblmdb/liblmdb.a) + +add_library(epee STATIC IMPORTED) +set_target_properties(epee PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/contrib/epee/src/libepee.a) + +############ +# Unbound +############ + +find_package(Unbound) +if(NOT UNBOUND_INCLUDE_DIR) + message(FATAL_ERROR "Could not find libunbound") +else() + message(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") + if(UNBOUND_LIBRARIES) + message(STATUS "Found libunbound library") + if (WIN32) + add_library(unbound STATIC IMPORTED) + else() + add_library(unbound SHARED IMPORTED) + endif() + set_target_properties(unbound PROPERTIES IMPORTED_LOCATION ${UNBOUND_LIBRARIES}) + else() + message(FATAL_ERROR "Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent") + endif() +endif() + +add_library(rpc_base STATIC IMPORTED) +set_target_properties(rpc_base PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/rpc/librpc_base.a) + +add_library(net STATIC IMPORTED) +set_target_properties(net PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/net/libnet.a) + +add_library(hardforks STATIC IMPORTED) +set_target_properties(hardforks PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/hardforks/libhardforks.a) + +add_library(easylogging STATIC IMPORTED) +set_target_properties(easylogging PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/external/easylogging++/libeasylogging.a) + +add_library(cryptonote_core STATIC IMPORTED) +set_target_properties(cryptonote_core PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/cryptonote_core/libcryptonote_core.a) + +add_library(cryptonote_protocol STATIC IMPORTED) +set_target_properties(cryptonote_protocol PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/cryptonote_protocol/libcryptonote_protocol.a) + +add_library(cryptonote_basic STATIC IMPORTED) +set_target_properties(cryptonote_basic PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/cryptonote_basic/libcryptonote_basic.a) + +add_library(cryptonote_format_utils_basic STATIC IMPORTED) +set_target_properties(cryptonote_format_utils_basic PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/cryptonote_basic/libcryptonote_format_utils_basic.a) + +add_library(mnemonics STATIC IMPORTED) +set_target_properties(mnemonics PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/mnemonics/libmnemonics.a) + +add_library(common STATIC IMPORTED) +set_target_properties(common PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/common/libcommon.a) + +add_library(cncrypto STATIC IMPORTED) +set_target_properties(cncrypto PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/crypto/libcncrypto.a) + +add_library(ringct STATIC IMPORTED) +set_target_properties(ringct PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/ringct/libringct.a) + +add_library(ringct_basic STATIC IMPORTED) +set_target_properties(ringct_basic PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/ringct/libringct_basic.a) + +add_library(blockchain_db STATIC IMPORTED) +set_target_properties(blockchain_db PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/blockchain_db/libblockchain_db.a) + +add_library(blocks STATIC IMPORTED) +set_target_properties(blocks PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/blocks/libblocks.a) + +add_library(checkpoints STATIC IMPORTED) +set_target_properties(checkpoints PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/checkpoints/libcheckpoints.a) + +add_library(device STATIC IMPORTED) +set_target_properties(device PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/device/libdevice.a) + +add_library(device_trezor STATIC IMPORTED) +set_target_properties(device_trezor PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/device_trezor/libdevice_trezor.a) + +add_library(multisig STATIC IMPORTED) +set_target_properties(multisig PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/multisig/libmultisig.a) + +add_library(version STATIC IMPORTED) +set_target_properties(version PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/src/libversion.a) + +add_library(randomx STATIC IMPORTED) +set_target_properties(randomx PROPERTIES IMPORTED_LOCATION + ${MONERO_PROJECT_BUILD}/external/randomx/librandomx.a) + +######################## +# Build c++ library +######################## + +message(STATUS ${ROOT_DIR}) +set( + LIBRARY_SRC_FILES + ${ROOT_DIR}/src/utils/gen_utils.cpp + ${ROOT_DIR}/src/utils/monero_utils.cpp + ${ROOT_DIR}/src/daemon/monero_daemon_model.cpp + ${ROOT_DIR}/src/daemon/monero_daemon.cpp + ${ROOT_DIR}/src/wallet/monero_wallet_model.cpp + ${ROOT_DIR}/src/wallet/monero_wallet_keys.cpp + ${ROOT_DIR}/src/wallet/monero_wallet_full.cpp +) +if (BUILD_LIBRARY) + add_library(monero-cpp SHARED ${LIBRARY_SRC_FILES}) + + target_include_directories(monero-cpp PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + "${ROOT_DIR}/src" + "${MONERO_PROJECT}/contrib/epee/include" + "${MONERO_PROJECT}/external/" + "${MONERO_PROJECT}/external/easylogging++" + "${MONERO_PROJECT}/external/rapidjson/include" + "${MONERO_PROJECT_SRC}/" + "${MONERO_PROJECT_SRC}/wallet" + "${MONERO_PROJECT_SRC}/wallet/api" + "${MONERO_PROJECT_SRC}/hardforks" + "${MONERO_PROJECT_SRC}/crypto" + "${MONERO_PROJECT_SRC}/crypto/crypto_ops_builder/include/" + ${Protobuf_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} + ${OPENSSL_INCLUDE_DIR} + ${ROOT_DIR}/external/libsodium/include/sodium + ${ROOT_DIR}/external/openssl-sdk/include + ${HIDAPI_INCLUDE_DIR} + ${UNBOUND_INCLUDE_DIR} + ) + + target_link_libraries(monero-cpp + wallet + rpc_base + net + lmdb + unbound + easylogging + cryptonote_core + cryptonote_protocol + cryptonote_basic + cryptonote_format_utils_basic + mnemonics + ringct + ringct_basic + common + cncrypto + blockchain_db + blocks + checkpoints + device + device_trezor + multisig + version + randomx + epee + hardforks + ${wallet_crypto} + + ${UNBOUND_LIBRARIES} + ${Boost_LIBRARIES} + ${Protobuf_LIBRARY} + ${LibUSB_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${SODIUM_LIBRARY} + ${HIDAPI_LIBRARIES} + ${EXTRA_LIBRARIES} + ) + +if (WIN32) + target_link_options(monero-cpp PUBLIC "-Wl,--enable-auto-import,--export-all-symbols") +endif() + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_options(monero-cpp PRIVATE "-z" "noexecstack") +endif() + + INSTALL(FILES src/daemon/monero_daemon.h + src/daemon/monero_daemon_model.h + DESTINATION include/daemon) + INSTALL(FILES src/utils/gen_utils.h + src/utils/monero_utils.h + DESTINATION include/utils) + INSTALL(FILES src/wallet/monero_wallet_full.h + src/wallet/monero_wallet.h + src/wallet/monero_wallet_keys.h + src/wallet/monero_wallet_model.h + DESTINATION include/wallet) + INSTALL(TARGETS monero-cpp + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development) +endif() + +######################## +# Build C++ sample Code +######################## + +if (BUILD_SAMPLE) + set(SAMPLE_CODE_SRC_FILES test/sample_code.cpp) + + add_executable(sample_code ${LIBRARY_SRC_FILES} ${SAMPLE_CODE_SRC_FILES}) + + target_include_directories(sample_code PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + src + "${MONERO_PROJECT}/contrib/epee/include" + "${MONERO_PROJECT}/external/" + "${MONERO_PROJECT}/external/easylogging++" + "${MONERO_PROJECT}/external/rapidjson/include" + "${MONERO_PROJECT_SRC}/" + "${MONERO_PROJECT_SRC}/wallet" + "${MONERO_PROJECT_SRC}/wallet/api" + "${MONERO_PROJECT_SRC}/hardforks" + "${MONERO_PROJECT_SRC}/crypto" + "${MONERO_PROJECT_SRC}/crypto/crypto_ops_builder/include/" + ${Protobuf_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} + ${OPENSSL_INCLUDE_DIR} + external/libsodium/include/sodium + external/openssl-sdk/include + ${HIDAPI_INCLUDE_DIR} + ${UNBOUND_INCLUDE_DIR} + ) + + target_link_libraries(sample_code + wallet + rpc_base + net + lmdb + easylogging + cryptonote_core + cryptonote_protocol + cryptonote_basic + cryptonote_format_utils_basic + mnemonics + ringct + ringct_basic + common + cncrypto + blockchain_db + blocks + checkpoints + device + device_trezor + multisig + version + randomx + epee + hardforks + ${wallet_crypto} + + ${UNBOUND_LIBRARIES} + ${Boost_LIBRARIES} + ${Protobuf_LIBRARY} + ${LibUSB_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${SODIUM_LIBRARY} + ${HIDAPI_LIBRARIES} + ${EXTRA_LIBRARIES} + ) + if (NOT WIN32) + target_link_libraries(sample_code dl) + endif() +endif() + +######################## +# Build C++ scratchpad +######################## + +if (BUILD_SCRATCHPAD) + set(SCRATCHPAD_SRC_FILES test/scratchpad.cpp) + + add_executable(scratchpad ${LIBRARY_SRC_FILES} ${SCRATCHPAD_SRC_FILES}) + + target_include_directories(scratchpad PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + src + "${MONERO_PROJECT}/contrib/epee/include" + "${MONERO_PROJECT}/external/" + "${MONERO_PROJECT}/external/easylogging++" + "${MONERO_PROJECT}/external/rapidjson/include" + "${MONERO_PROJECT_SRC}/" + "${MONERO_PROJECT_SRC}/wallet" + "${MONERO_PROJECT_SRC}/wallet/api" + "${MONERO_PROJECT_SRC}/hardforks" + "${MONERO_PROJECT_SRC}/crypto" + "${MONERO_PROJECT_SRC}/crypto/crypto_ops_builder/include/" + ${Protobuf_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} + ${OPENSSL_INCLUDE_DIR} + external/libsodium/include/sodium + external/openssl-sdk/include + ${HIDAPI_INCLUDE_DIR} + ${UNBOUND_INCLUDE_DIR} + ) + + target_link_libraries(scratchpad + wallet + rpc_base + net + lmdb + easylogging + cryptonote_core + cryptonote_protocol + cryptonote_basic + cryptonote_format_utils_basic + mnemonics + ringct + ringct_basic + common + cncrypto + blockchain_db + blocks + checkpoints + device + device_trezor + multisig + version + randomx + epee + hardforks + ${wallet_crypto} + + ${UNBOUND_LIBRARIES} + ${Boost_LIBRARIES} + ${Protobuf_LIBRARY} + ${LibUSB_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${SODIUM_LIBRARY} + ${HIDAPI_LIBRARIES} + ${EXTRA_LIBRARIES} + ) + if (NOT WIN32) + target_link_libraries(scratchpad dl) + endif() +endif() + +######################## +# Build C++ tests +######################## + +if (BUILD_TESTS) + set(TEST_SRC_FILES test/monero_tests.cpp) + + add_executable(monero_tests ${LIBRARY_SRC_FILES} ${TEST_SRC_FILES}) + + target_include_directories(monero_tests PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + src + "${MONERO_PROJECT}/contrib/epee/include" + "${MONERO_PROJECT}/external/" + "${MONERO_PROJECT}/external/easylogging++" + "${MONERO_PROJECT}/external/rapidjson/include" + "${MONERO_PROJECT_SRC}/" + "${MONERO_PROJECT_SRC}/wallet" + "${MONERO_PROJECT_SRC}/wallet/api" + "${MONERO_PROJECT_SRC}/hardforks" + "${MONERO_PROJECT_SRC}/crypto" + "${MONERO_PROJECT_SRC}/crypto/crypto_ops_builder/include/" + ${Protobuf_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} + ${OPENSSL_INCLUDE_DIR} + external/libsodium/include/sodium + external/openssl-sdk/include + ${HIDAPI_INCLUDE_DIR} + ${UNBOUND_INCLUDE_DIR} + ) + + target_link_libraries(monero_tests + wallet + rpc_base + net + lmdb + easylogging + cryptonote_core + cryptonote_protocol + cryptonote_basic + cryptonote_format_utils_basic + mnemonics + ringct + ringct_basic + common + cncrypto + blockchain_db + blocks + checkpoints + device + device_trezor + multisig + version + randomx + epee + hardforks + ${wallet_crypto} + + ${UNBOUND_LIBRARIES} + ${Boost_LIBRARIES} + ${Protobuf_LIBRARY} + ${LibUSB_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${SODIUM_LIBRARY} + ${HIDAPI_LIBRARIES} + ${EXTRA_LIBRARIES} + ) + if (NOT WIN32) + target_link_libraries(monero_tests dl) + endif() +endif() diff --git a/macos_universal/arm/build.sh b/macos_universal/arm/build.sh new file mode 100755 index 00000000..8dd8c87c --- /dev/null +++ b/macos_universal/arm/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +cd build && cmake -DCMAKE_TOOLCHAIN_FILE=../../../external/monero-project/contrib/depends/aarch64-apple-darwin11/share/toolchain.cmake .. && make diff --git a/macos_universal/arm/clean.sh b/macos_universal/arm/clean.sh new file mode 100755 index 00000000..ff922fc3 --- /dev/null +++ b/macos_universal/arm/clean.sh @@ -0,0 +1,2 @@ +#!/bin/bash +cd build && rm -f CMakeCache.txt && rm -rf CMakeFiles && rm -rf cmake_install.cmake && rm -f libmonero-cpp.dylib && rm -f Makefile diff --git a/macos_universal/arm/cmake b/macos_universal/arm/cmake new file mode 120000 index 00000000..745c85c0 --- /dev/null +++ b/macos_universal/arm/cmake @@ -0,0 +1 @@ +../../cmake \ No newline at end of file diff --git a/macos_universal/arm/root b/macos_universal/arm/root new file mode 120000 index 00000000..c25bddb6 --- /dev/null +++ b/macos_universal/arm/root @@ -0,0 +1 @@ +../.. \ No newline at end of file diff --git a/macos_universal/build.sh b/macos_universal/build.sh new file mode 100755 index 00000000..3ced3820 --- /dev/null +++ b/macos_universal/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +cd universal && ./combine_and_build_all.sh diff --git a/macos_universal/universal/.combine.sh.swp b/macos_universal/universal/.combine.sh.swp new file mode 100644 index 0000000000000000000000000000000000000000..b850ed09f2aedc0b283b283fc2b6e951abf9d8ef GIT binary patch literal 12288 zcmeI&Jx;?g7zSXs3ll$r3%FG3mbe8}fy4zmFv40nu?wye+j5*z7Pty$;2bPWTmvKy zfYUTWMHQW?UMrSk`%`Q`QidpB(!Uv9(TliGLOBTa@_90PZIkzx9a0w3Rl}Q#kTaPX zyD5x3Ru5#i%Cp>P=}a``GtT7POQ(6(45rqyoTsK3ms-uFE5g*zU25_~X&D!H8<#@> z1R$^?uuD!)28&m{d)%Q%hu15!=s*Ah5P$##AOHafKmY>UE#Pg7JcT2+m&a_{*0SHU z+pU1pK>z{}fB*y_009U<00Izz00g#MfD1z2_6Ye5wfg_xeE)y#*JB^mI0^(H009U< z00Izz00bZa0SG|gzX_y*CZ);*?e(b3X*8jkN|yQPA@w{K520U8#xbj}-wEp0nW;=Y zOO5tUB}_;wwJ6y9d^jGSMcmp Date: Wed, 24 Jul 2024 19:45:54 -0400 Subject: [PATCH 2/6] build script --- macos_universal/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/macos_universal/build.sh b/macos_universal/build.sh index 3ced3820..214091bf 100755 --- a/macos_universal/build.sh +++ b/macos_universal/build.sh @@ -1,2 +1,5 @@ #!/bin/bash +cd .. && ./bin/update_submodules.sh +cd ../external/monero-project && make depends target=x86_64-apple-darwin11 +cd ../external/monero-project && make depends target=aarch64-apple-darwin11 cd universal && ./combine_and_build_all.sh From 19c10b71589d06947e0cd747407c38ad12adf657 Mon Sep 17 00:00:00 2001 From: preland Date: Wed, 24 Jul 2024 21:51:07 -0400 Subject: [PATCH 3/6] finished build --- macos_universal/build.sh | 7 ++++--- macos_universal/universal/combine_and_build_all.sh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/macos_universal/build.sh b/macos_universal/build.sh index 214091bf..5d5342ef 100755 --- a/macos_universal/build.sh +++ b/macos_universal/build.sh @@ -1,5 +1,6 @@ #!/bin/bash cd .. && ./bin/update_submodules.sh -cd ../external/monero-project && make depends target=x86_64-apple-darwin11 -cd ../external/monero-project && make depends target=aarch64-apple-darwin11 -cd universal && ./combine_and_build_all.sh +cd external/monero-project && make depends target=x86_64-apple-darwin11 +make depends target=aarch64-apple-darwin11 + +cd ../../macos_universal/universal && ./combine_and_build_all.sh diff --git a/macos_universal/universal/combine_and_build_all.sh b/macos_universal/universal/combine_and_build_all.sh index 6bb4fd44..b09f4d94 100755 --- a/macos_universal/universal/combine_and_build_all.sh +++ b/macos_universal/universal/combine_and_build_all.sh @@ -5,4 +5,4 @@ cd ../arm && ./clean.sh && ./build.sh # build x86 cd ../x86 && ./clean.sh && ./build.sh # combine -./combine.sh +cd ../universal && ./combine.sh From a1243698d222bcc0fcc35b6d75481de847eeffa8 Mon Sep 17 00:00:00 2001 From: preland <89992615+preland@users.noreply.github.com> Date: Wed, 24 Jul 2024 21:59:34 -0400 Subject: [PATCH 4/6] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0afbd7d..aa8fc3ba 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,8 @@ For example, [monero-java](https://github.com/woodser/monero-java) compiles this ``` 4. Build monero-project, located as a submodule at ./external/monero-project. Install [dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system, then build with e.g.: `make release-static -j6` 5. Link to this library's source files in your application, or build monero-cpp to a shared library in ./build: `./bin/build_libmonero_cpp.sh` - +> Note: The above process will only build a native macOS binary dependent on your device's platform. To create a universal binary, use the build.sh script provided in [macos_universal](macos_universal). +> CAVEATS: This script MUST BE RAN FROM WITHIN THE macos_universal directory. As of writing, the script has only been verified to work properly on a Debian 12 system. In theory, there is nothing stopping the universal binary from being cross-compiled on other platforms, although Windows in particular would require some extra changes in order to work. ### Windows 1. Download and install [MSYS2](https://www.msys2.org/). From aea9f867f96e06d81503ef87600be34931e0b635 Mon Sep 17 00:00:00 2001 From: preland Date: Wed, 24 Jul 2024 22:15:31 -0400 Subject: [PATCH 5/6] oops that shouldn't be in a PR --- macos_universal/universal/.combine.sh.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 macos_universal/universal/.combine.sh.swp diff --git a/macos_universal/universal/.combine.sh.swp b/macos_universal/universal/.combine.sh.swp deleted file mode 100644 index b850ed09f2aedc0b283b283fc2b6e951abf9d8ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&Jx;?g7zSXs3ll$r3%FG3mbe8}fy4zmFv40nu?wye+j5*z7Pty$;2bPWTmvKy zfYUTWMHQW?UMrSk`%`Q`QidpB(!Uv9(TliGLOBTa@_90PZIkzx9a0w3Rl}Q#kTaPX zyD5x3Ru5#i%Cp>P=}a``GtT7POQ(6(45rqyoTsK3ms-uFE5g*zU25_~X&D!H8<#@> z1R$^?uuD!)28&m{d)%Q%hu15!=s*Ah5P$##AOHafKmY>UE#Pg7JcT2+m&a_{*0SHU z+pU1pK>z{}fB*y_009U<00Izz00g#MfD1z2_6Ye5wfg_xeE)y#*JB^mI0^(H009U< z00Izz00bZa0SG|gzX_y*CZ);*?e(b3X*8jkN|yQPA@w{K520U8#xbj}-wEp0nW;=Y zOO5tUB}_;wwJ6y9d^jGSMcmp Date: Mon, 26 Aug 2024 12:34:34 -0500 Subject: [PATCH 6/6] switch monero repo to upstream --- external/monero-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/monero-project b/external/monero-project index b089f9ee..a1dc85c5 160000 --- a/external/monero-project +++ b/external/monero-project @@ -1 +1 @@ -Subproject commit b089f9ee69924882c5d14dd1a6991deb05d9d1cd +Subproject commit a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623