From 4245e8c147f3bc3512352b73462774c042426e81 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 10 Aug 2021 10:16:44 +0200 Subject: Refactor gn target Currently we get hangs on ci, to investigate the issue go through current cmake code and: * remove all dummy ninja targets * remove implicit dependencies * build dir in form of buildDir/config/arch * separate ninja call for sandbox * separate ninja call for covert_dict * clean up universal build * change handling of rsp files, so they are generated during build and not configure time * refactor functions so universal build can be easily used by follow up qtpdf patch Change-Id: Id4a6c61b87fe76832232035fddf212b57051d0ec Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 58b787cbad581914367aea4604993cce30a65d06) Reviewed-by: Qt Cherry-pick Bot --- src/core/CMakeLists.txt | 159 +++++++++++++--------------------------- src/core/configure/rsp.cmake.in | 5 ++ 2 files changed, 54 insertions(+), 110 deletions(-) create mode 100644 src/core/configure/rsp.cmake.in (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 783a3b03a..398e8412c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -39,32 +39,19 @@ endif() # MULTICONFIG SETUP ## -if(QT_GENERATOR_IS_MULTI_CONFIG) - set(configs ${CMAKE_CONFIGURATION_TYPES}) -else() - set(configs ${CMAKE_BUILD_TYPE}) -endif() - -if(NOT QT_IS_MACOS_UNIVERSAL) - set(GN_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) -else() - set(GN_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES}) -endif() - -foreach(arch ${GN_ARCHITECTURES}) - if(QT_IS_MACOS_UNIVERSAL) - set(buildDir "${CMAKE_CURRENT_BINARY_DIR}/${arch}") - endif() +get_configs(configs) +get_architectures(archs) +foreach(arch ${archs}) foreach(config ${configs}) - ## - # BUILD.gn SETUP - ## - unset(buildGn) - set(buildGn buildGnWebEngineCore_${config}_${arch}) + ## + # BUILD.gn SETUP + ## - add_gn_target(${buildGn} SOURCES DEFINES CXX_COMPILE_OPTIONS C_COMPILE_OPTIONS INCLUDES) + unset(buildGn) + set(buildGn core_${config}_${arch}) + add_gn_target(${buildGn} ${config} ${arch} SOURCES DEFINES CXX_COMPILE_OPTIONS C_COMPILE_OPTIONS INCLUDES) resolve_target_includes(gnIncludes WebEngineCore) get_forward_declaration_macro(forwardDeclarationMacro) @@ -283,12 +270,12 @@ foreach(arch ${GN_ARCHITECTURES}) read_gn_target(${buildGn} ${WEBENGINE_ROOT_BUILD_DIR}/src/core/api/${config}/gn_config.cxx.cmake) read_gn_target(${buildGn} ${WEBENGINE_ROOT_BUILD_DIR}/src/core/api/${config}/gn_config.c.cmake) configure_gn_target(${buildGn} ${config} - ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.root.gn.in ${buildDir}/${config}/BUILD.gn) + ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.root.gn.in ${buildDir}/${config}/${arch}/BUILD.gn) - ## - # GN PARAMETERS SETUP - ## + ## + # GN PARAMETERS SETUP + ## unset(gnArgArg) @@ -299,7 +286,7 @@ foreach(arch ${GN_ARCHITECTURES}) append_pkg_config_setup(gnArgArg) list(APPEND gnArgArg - qtwebengine_target="${buildDir}/${config}:QtWebEngineCore" + qtwebengine_target="${buildDir}/${config}/${arch}:QtWebEngineCore" enable_media_remoting=false enable_message_center=false enable_nacl=false @@ -461,85 +448,47 @@ foreach(arch ${GN_ARCHITECTURES}) ) endif() - - ## - # GN CALL - ## + ## + # GN CALL + ## execute_gn(gnArgArg) - ## - # NINJA CALL - ## - - # config loop is a workaround to be able to add_custom_command per config - # note this is fixed in CMAKE.3.20 and should be cleaned up when 3.20 is - # the minimum cmake we support - - if(WIN32) - set(sandboxOutput ${buildDir}/${config}/QtWebEngineCoreSandbox.lib) - set(sandboxTarget QtWebEngineCoreSandbox) - else() - unset(sandboxOutput) - unset(sandboxTarget) - endif() - - execute_ninja(QtWebEngineCore ${sandboxTarget}) - endforeach() endforeach() ## -# WEBENGINECORE SETUP +# WEBENGINECORE ## -if (QT_IS_MACOS_UNIVERSAL) - target_include_directories(WebEngineCore PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/$/gen - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/$/gen/third_party/perfetto - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/$/gen/third_party/perfetto/build_config - ) -else() - target_include_directories(WebEngineCore PRIVATE - ${buildDir}/$/gen - ${buildDir}/$/gen/third_party/perfetto - ${buildDir}/$/gen/third_party/perfetto/build_config - ) -endif() - -if (QT_IS_MACOS_UNIVERSAL) - - set(buildDir "${CMAKE_CURRENT_BINARY_DIR}") - foreach(config ${configs}) - - extend_target_with_gn_libs(WebEngineCore ${config} QtWebEngineCore.cmake QtWebEngineCore.stamp) - endforeach() - # in the end, set the build dir back to one of the archs, to make sure the resources get copied alright - set(buildDir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}") +set(arch ${CMAKE_SYSTEM_PROCESSOR}) +target_include_directories(WebEngineCore PRIVATE + ${buildDir}/$/${arch}/gen + ${buildDir}/$/${arch}/gen/third_party/perfetto + ${buildDir}/$/${arch}/gen/third_party/perfetto/build_config +) -else() +add_gn_build_aritfacts_to_target(WebEngineCore QtWebEngineCore ON ${buildDir}) - if(WIN32) - add_library(WebEngineCoreSandbox STATIC IMPORTED GLOBAL) - add_dependencies(WebEngineCoreSandbox ninja) - endif() +## +# SANDBOX +## +if(WIN32) + add_library(WebEngineCoreSandbox STATIC IMPORTED GLOBAL) foreach(config ${configs}) - - extend_target_with_gn_objects(WebEngineCore ${config} QtWebEngineCore.cmake QtWebEngineCore.stamp) - - if(WIN32) - string(TOUPPER ${config} cfg) - set(sandboxLibraryPath ${buildDir}/${config}/QtWebEngineCoreSandbox.lib) - set_property(TARGET WebEngineCoreSandbox - PROPERTY IMPORTED_LOCATION_${cfg} ${sandboxLibraryPath}) - set_source_files_properties(${sandboxLibraryPath} PROPERTIES GENERATED TRUE) - add_custom_command(OUTPUT ${sandboxLibraryPath} DEPENDS ${sandboxOutput}) - add_custom_target(generate_sandbox_${cfg} DEPENDS ${sandboxLibraryPath}) - endif() - + string(TOUPPER ${config} cfg) + add_ninja_command("" WebEngineCoreSandbox QtWebEngineCoreSandbox + QtWebEngineCoreSandbox.lib ${buildDir}/${config}/${arch} + ) + set(sandboxLibraryPath ${buildDir}/${config}/${arch}/QtWebEngineCoreSandbox.lib) + set_property(TARGET WebEngineCoreSandbox + PROPERTY IMPORTED_LOCATION_${cfg} ${sandboxLibraryPath} + ) + add_custom_target(sandboxLibrary_${config} + DEPENDS ${buildDir}/${config}/${arch}/QtWebEngineCoreSandbox.lib) + add_dependencies(WebEngineCoreSandbox sandboxLibrary_${config}) endforeach() - endif() ## @@ -559,17 +508,17 @@ set(resourceList qtwebengine_resources.pak get_install_config(config) foreach(loc ${localeList}) - get_filename_component(locSourcePath ${buildDir}/${config}/qtwebengine_locales/${loc}.pak REALPATH) + get_filename_component(locSourcePath ${buildDir}/${config}/${arch}/qtwebengine_locales/${loc}.pak REALPATH) list(APPEND localeFiles ${locSourcePath}) endforeach() foreach(res ${resourceList}) - get_filename_component(resSourcePath ${buildDir}/${config}/${res} REALPATH) + get_filename_component(resSourcePath ${buildDir}/${config}/${arch}/${res} REALPATH) list(APPEND resourceFiles ${resSourcePath}) endforeach() if (NOT QT_FEATURE_webengine_system_icu) - get_filename_component(icuFile ${buildDir}/${config}/icudtl.dat REALPATH) + get_filename_component(icuFile ${buildDir}/${config}/${arch}/icudtl.dat REALPATH) list(APPEND resourceFiles ${icuFile}) endif() @@ -588,7 +537,7 @@ if(QT_FEATURE_framework) GENERATED TRUE ) - add_custom_command(OUTPUT ${allResourceFiles} DEPENDS ${buildDir}/${config}/QtWebEngineCore.stamp) + add_custom_command(OUTPUT ${allResourceFiles} DEPENDS ${buildDir}/${config}/${arch}/QtWebEngineCore.stamp) add_custom_target(generate_resources_${config} DEPENDS ${allResourceFiles}) else() install(FILES ${localeFiles} @@ -613,7 +562,7 @@ else() add_custom_target( install_resources_${config} ALL - DEPENDS ${buildDir}/${config}/QtWebEngineCore.stamp + DEPENDS ${buildDir}/${config}/${arch}/QtWebEngineCore.stamp COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_PREFIX}/resources COMMAND ${CMAKE_COMMAND} -E copy @@ -622,7 +571,7 @@ else() add_custom_target( install_locales_${config} ALL - DEPENDS ${buildDir}/${config}/QtWebEngineCore.stamp + DEPENDS ${buildDir}/${config}/${arch}/QtWebEngineCore.stamp COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_PREFIX}/translations/qtwebengine_locales COMMAND ${CMAKE_COMMAND} -E copy @@ -640,18 +589,8 @@ if(QT_FEATURE_webengine_spellchecker) target_include_directories(${dict_target_name} PRIVATE ../3rdparty/chromium ../3rdparty/chromium/third_party/boringssl/src/include - ${buildDir}/${config}/gen + ${buildDir}/${config}/${arch}/gen ) - if(QT_IS_MACOS_UNIVERSAL) - set(buildDir "${CMAKE_CURRENT_BINARY_DIR}") - foreach(config ${configs}) - extend_target_with_gn_libs(${dict_target_name} ${config} convert_dict.cmake QtWebEngineCore.stamp) - endforeach() - - else() - foreach(config ${configs}) - extend_target_with_gn_objects(${dict_target_name} ${config} convert_dict.cmake "") - endforeach() - endif() + add_gn_build_aritfacts_to_target(${dict_target_name} convert_dict OFF ${buildDir}) endif() diff --git a/src/core/configure/rsp.cmake.in b/src/core/configure/rsp.cmake.in new file mode 100644 index 000000000..d24299007 --- /dev/null +++ b/src/core/configure/rsp.cmake.in @@ -0,0 +1,5 @@ +include(@CMAKE_FILE@) +list(JOIN @CONFIG@_NINJA_OBJECTS " " objects) +list(JOIN @CONFIG@_NINJA_ARCHIVES " " archives) +file(WRITE ${CMAKE_CURRENT_LIST_DIR}/@TARGET@_gnobjects.rsp ${objects}) +file(WRITE ${CMAKE_CURRENT_LIST_DIR}/@TARGET@_gnarchives.rsp ${archives}) -- cgit v1.2.3