diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d0dd1d3..096b560f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,15 +6,28 @@ jobs: build-macos: runs-on: macOS-latest + strategy: + fail-fast: false + matrix: + toolchain: + - name: "qmake" + cmd: "export PATH=$PATH:/usr/local/opt/qt/bin && ./build.sh" + output: build/release/bin/monero-wallet-gui.app/Contents/MacOS/monero-wallet-gui + - name: "cmake" + cmd: "USE_SINGLE_BUILDDIR=ON DEV_MODE=ON make release -j3" + output: build/release/bin/monero-wallet-gui + name: build-macos-${{ matrix.toolchain.name }} steps: - uses: actions/checkout@v1 + with: + submodules: recursive - name: update brew and install dependencies - run: brew update && brew install boost hidapi zmq libpgm miniupnpc ldns expat libunwind-headers protobuf qt5 libgcrypt + run: brew update && brew install boost hidapi zmq libpgm miniupnpc ldns expat libunwind-headers protobuf qt5 pkg-config - name: build - run: export PATH=$PATH:/usr/local/opt/qt/bin && ./build.sh + run: ${{ matrix.toolchain.cmd }} - name: test qml - run: build/release/bin/monero-wallet-gui.app/Contents/MacOS/monero-wallet-gui --test-qml + run: ${{ matrix.toolchain.output }} --test-qml build-ubuntu: diff --git a/CMakeLists.txt b/CMakeLists.txt index 298902f8..f8431d5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ endif() set(BUILD_GUI_DEPS ON) set(ARCH "x86-64") set(BUILD_64 ON) -set(INSTALL_VENDORED_LIBUNBOUND ${STATIC}) function (add_c_flag_if_supported flag var) string(REPLACE "-" "_" supported ${flag}_c) @@ -82,6 +81,7 @@ endif() add_subdirectory(monero) set_property(TARGET wallet_merged PROPERTY FOLDER "monero") get_directory_property(ARCH_WIDTH DIRECTORY "monero" DEFINITION ARCH_WIDTH) +get_directory_property(UNBOUND_LIBRARY DIRECTORY "monero" DEFINITION UNBOUND_LIBRARY) if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DQT_NO_DEBUG) @@ -139,6 +139,9 @@ monero_gui_add_library(gui_version SOURCES version.js DEPENDS genversiongui) message(STATUS "${CMAKE_MODULE_PATH}") # OpenSSL +if(APPLE AND NOT OPENSSL_ROOT_DIR) + execute_process(COMMAND brew --prefix openssl OUTPUT_VARIABLE OPENSSL_ROOT_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() find_package(OpenSSL REQUIRED) message(STATUS "OpenSSL: Version ${OPENSSL_VERSION}") message(STATUS "OpenSSL: include dir at ${OPENSSL_INCLUDE_DIR}") @@ -170,6 +173,9 @@ message(STATUS "libhidapi: libraries at ${HIDAPI_LIBRARIES}") if(DEBUG) set(Boost_DEBUG ON) endif() +if(APPLE AND NOT BOOST_ROOT) + execute_process(COMMAND brew --prefix boost OUTPUT_VARIABLE BOOST_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() find_package(Boost 1.58 REQUIRED COMPONENTS system filesystem @@ -222,6 +228,19 @@ if(WITH_SCANNER) list(APPEND QT5_LIBRARIES Qt5Multimedia) endif() +if(APPLE) + list(APPEND QT5_LIBRARIES Qt5MacExtras) + + if(NOT CMAKE_PREFIX_PATH) + execute_process(COMMAND brew --prefix qt5 OUTPUT_VARIABLE QT5_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + list(APPEND CMAKE_PREFIX_PATH ${QT5_DIR}) + endif() + + if(CMAKE_PREFIX_PATH) + include_directories(${CMAKE_PREFIX_PATH}/include) + endif() +endif() + # TODO: drop this once we switch to Qt 5.14+ find_package(Qt5QmlModels QUIET) if(Qt5QmlModels_FOUND) @@ -247,6 +266,11 @@ if(QT5_PKG_CONFIG_FOUND) set(QT5_PKG_CONFIG "${QT5_PKG_CONFIG}_STATIC") endif() + if(APPLE) + list(JOIN ${QT5_PKG_CONFIG}_LDFLAGS_OTHER " " ${QT5_PKG_CONFIG}_LDFLAGS_OTHER) + list(JOIN ${QT5_PKG_CONFIG}_LIBRARIES " " ${QT5_PKG_CONFIG}_LIBRARIES) + endif() + set(QT5_LIBRARIES ${${QT5_PKG_CONFIG}_LIBRARIES} ${${QT5_PKG_CONFIG}_LDFLAGS_OTHER}) include_directories(${${QT5_PKG_CONFIG}_INCLUDE_DIRS}) link_directories(${${QT5_PKG_CONFIG}_LIBRARY_DIRS}) @@ -361,7 +385,9 @@ if(MINGW) else() set(ICU_LIBRARIES icuio icuin icuuc icudt icutu iconv) endif() -elseif(APPLE OR OPENBSD OR ANDROID) +elseif(APPLE) + set(EXTRA_LIBRARIES "-framework AppKit") +elseif(OPENBSD OR ANDROID) set(EXTRA_LIBRARIES "") elseif(FREEBSD) set(EXTRA_LIBRARIES execinfo) @@ -425,7 +451,7 @@ if (NOT (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VER endif() # linker -if (NOT (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU")) +if (NOT APPLE AND NOT (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU")) # Windows binaries die on startup with PIE when compiled with GCC add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS) endif() @@ -488,6 +514,5 @@ if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED) endif() add_subdirectory(translations) -get_directory_property(TRANSLATIONS_QRC DIRECTORY translations DEFINITION TRANSLATIONS_QRC) add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8800c2fb..b73bff79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ add_subdirectory(model) add_subdirectory(openpgp) add_subdirectory(zxcvbn-c) -qt5_add_resources(RESOURCES ../qml.qrc ${TRANSLATIONS_QRC}) +qt5_add_resources(RESOURCES ../qml.qrc) # Compile source files (.h/.cpp) file(GLOB SOURCE_FILES @@ -44,13 +44,16 @@ file(GLOB SOURCE_FILES "libwalletqt/Subaddress.h" "libwalletqt/SubaddressAccount.h" "libwalletqt/UnsignedTransaction.h" - "daemon/*.h" - "daemon/*.cpp" - "model/*.h" - "model/*.cpp" - "qt/*.h" + "daemon/*.h" + "daemon/*.cpp" + "model/*.h" + "model/*.cpp" + "qt/*.h" "qt/*.cpp" ) +if(APPLE) + list(APPEND SOURCE_FILES "qt/macoshelper.mm") +endif() if(ENABLE_PASS_STRENGTH_METER) file(GLOB PASS_STRENGTH_FILES @@ -130,7 +133,7 @@ target_link_libraries(monero-wallet-gui wallet_merged ${LMDB_LIBRARY} epee - unbound + ${UNBOUND_LIBRARY} ${SODIUM_LIBRARY} easylogging blockchain_db @@ -145,6 +148,7 @@ target_link_libraries(monero-wallet-gui ${EXTRA_LIBRARIES} ${ICU_LIBRARIES} openpgp + translations ) if(DEVICE_TREZOR_READY) diff --git a/src/main/main.cpp b/src/main/main.cpp index 18986409..d7788dc6 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -147,6 +147,8 @@ bool isOpenGL = true; int main(int argc, char *argv[]) { + Q_INIT_RESOURCE(translations); + // platform dependant settings #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) bool isDesktop = true; diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt index 8f1c0bc6..ab10fa4a 100644 --- a/translations/CMakeLists.txt +++ b/translations/CMakeLists.txt @@ -1,23 +1,48 @@ +find_package(Qt5Core REQUIRED) + +find_package(Qt5LinguistTools QUIET) +if(NOT Qt5_LRELEASE_EXECUTABLE) + find_program(Qt5_LRELEASE_EXECUTABLE lrelease REQUIRED) +endif() + file(GLOB TS_FILES *.ts) -set(QRC "") +set(QM_FILES) +set(QRC_CONTENTS "") foreach(TS_FILE ${TS_FILES}) get_filename_component(QM_FILE ${TS_FILE} NAME_WE) set(QM_FILE ${CMAKE_CURRENT_BINARY_DIR}/${QM_FILE}.qm) + list(APPEND QM_FILES ${QM_FILE}) - execute_process(COMMAND lrelease -compress -nounfinished -removeidentical ${TS_FILE} -qm ${QM_FILE} - RESULT_VARIABLE RET - OUTPUT_VARIABLE OUT - ERROR_VARIABLE ERR + add_custom_command( + OUTPUT ${QM_FILE} + COMMAND ${Qt5_LRELEASE_EXECUTABLE} -compress -nounfinished -removeidentical ${TS_FILE} -qm ${QM_FILE} + DEPENDS ${TS_FILE} ) - if(RET) - message(FATAL_ERROR "${TS_FILE}: lrelease returned non-zero exit code: ${RET} ${OUT} ${ERR}") - endif() get_filename_component(QM_FILE_NAME ${QM_FILE} NAME) - string(APPEND QRC "${QM_FILE_NAME}") + string(APPEND QRC_CONTENTS "${QM_FILE_NAME}") endforeach() -string(APPEND QRC "") +string(APPEND QRC_CONTENTS "") set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc) -file(WRITE ${TRANSLATIONS_QRC} ${QRC}) +add_custom_command( + OUTPUT ${TRANSLATIONS_QRC} + COMMAND echo ${QRC_CONTENTS} > ${TRANSLATIONS_QRC} + VERBATIM +) +set_source_files_properties(${TRANSLATIONS_QRC} PROPERTIES SKIP_AUTORCC ON) + +set(TRANSLATIONS_CPP ${CMAKE_CURRENT_BINARY_DIR}/qrc_translations.cpp) +add_custom_command( + OUTPUT ${TRANSLATIONS_CPP} + COMMAND ${Qt5Core_RCC_EXECUTABLE} + ARGS --name translations --output ${TRANSLATIONS_CPP} ${TRANSLATIONS_QRC} + MAIN_DEPENDENCY ${TRANSLATIONS_QRC} + DEPENDS ${QM_FILES} + VERBATIM +) +set_source_files_properties(${TRANSLATIONS_CPP} PROPERTIES SKIP_AUTOMOC ON) +set_source_files_properties(${TRANSLATIONS_CPP} PROPERTIES SKIP_AUTOUIC ON) + +add_library(translations ${TRANSLATIONS_CPP})