Merge pull request #2991

c9d36b1 cmake: translations deps handling, build translations as a library (xiphon)
d931022 cmake: implement MacOS 'release' build + CI support (xiphon)
This commit is contained in:
luigi1111 2020-07-14 15:46:09 -05:00
commit 1a51e93e55
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
5 changed files with 94 additions and 25 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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)

View file

@ -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;

View file

@ -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 "<RCC><qresource prefix=\"/\">")
set(QM_FILES)
set(QRC_CONTENTS "<RCC><qresource prefix=\"/\">")
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 "<file>${QM_FILE_NAME}</file>")
string(APPEND QRC_CONTENTS "<file>${QM_FILE_NAME}</file>")
endforeach()
string(APPEND QRC "</qresource></RCC>")
string(APPEND QRC_CONTENTS "</qresource></RCC>")
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})