From cd78cf27a19ecd20cfc3ad44b593b21d1ae2f249 Mon Sep 17 00:00:00 2001 From: Even Oscar Andersen Date: Mon, 24 Jun 2024 11:41:45 +0200 Subject: [PATCH] wasm: Fix conflict usage for tst_qwasmwindow_harness.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a default tst_qwasmwindow_harness.html created, and we have our own in addition. This creates problems if one runs configure and do not perform a clean build afterwards as we would be left with the autogenerated file. The solution is to rename our custom file so that there is no conflict. Change-Id: I1f0436eea752059d4dcf22407c760339eed46c09 Reviewed-by: Piotr WierciƄski --- cmake/QtTestHelpers.cmake | 8 +++ src/corelib/Qt6WasmMacros.cmake | 58 ++++++++++--------- tests/auto/wasm/selenium/CMakeLists.txt | 5 +- tests/auto/wasm/selenium/qwasmwindow.py | 2 +- ....html => tst_qwasmwindow_harness_run.html} | 0 5 files changed, 42 insertions(+), 31 deletions(-) rename tests/auto/wasm/selenium/{tst_qwasmwindow_harness.html => tst_qwasmwindow_harness_run.html} (100%) diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake index 2885b1508c6..071986122d9 100644 --- a/cmake/QtTestHelpers.cmake +++ b/cmake/QtTestHelpers.cmake @@ -217,6 +217,7 @@ function(qt_internal_get_test_arg_definitions optional_args single_value_args mu NO_BATCH NO_INSTALL BUNDLE_ANDROID_OPENSSL_LIBS + NO_WASM_DEFAULT_FILES PARENT_SCOPE ) set(${single_value_args} @@ -587,6 +588,13 @@ function(qt_internal_add_test name) endif() endif() + if (arg_NO_WASM_DEFAULT_FILES) + set_target_properties( + ${name} + PROPERTIES + NO_WASM_DEFAULT_FILES True) + endif() + foreach(path IN LISTS arg_QML_IMPORTPATH) list(APPEND extra_test_args "-import" "${path}") endforeach() diff --git a/src/corelib/Qt6WasmMacros.cmake b/src/corelib/Qt6WasmMacros.cmake index 283243006ad..9166b7fdf3d 100644 --- a/src/corelib/Qt6WasmMacros.cmake +++ b/src/corelib/Qt6WasmMacros.cmake @@ -56,41 +56,43 @@ function(_qt_internal_wasm_add_target_helpers target) configure_file("${WASM_BUILD_DIR}/libexec/util.js" "${target_output_directory}/util.js" COPYONLY) else() + get_target_property(no_wasm_files ${target} NO_WASM_DEFAULT_FILES) + if(target_output_directory) set(_target_directory "${target_output_directory}") else() set(_target_directory "${CMAKE_CURRENT_BINARY_DIR}") endif() - configure_file("${WASM_BUILD_DIR}/plugins/platforms/wasm_shell.html" - "${_target_directory}/${_target_output_name}.html" @ONLY) - if(CMAKE_CONFIGURATION_TYPES) # if multiconfig generator - add_custom_command( - TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${_target_directory}/${_target_output_name}.html" - ${_target_directory}/$/${_target_output_name}.html - ) - add_custom_command( - TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${WASM_BUILD_DIR}/plugins/platforms/qtloader.js" - ${_target_directory}/$/qtloader.js - ) - add_custom_command( - TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg" - ${_target_directory}/$/qtlogo.svg - ) - else() - configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtloader.js" - ${_target_directory}/qtloader.js COPYONLY) - configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg" - ${_target_directory}/qtlogo.svg COPYONLY) - + if (NOT no_wasm_files) + configure_file("${WASM_BUILD_DIR}/plugins/platforms/wasm_shell.html" + "${_target_directory}/${_target_output_name}.html" @ONLY) + if(CMAKE_CONFIGURATION_TYPES) # if multiconfig generator + add_custom_command( + TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${_target_directory}/${_target_output_name}.html" + ${_target_directory}/$/${_target_output_name}.html + ) + add_custom_command( + TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${WASM_BUILD_DIR}/plugins/platforms/qtloader.js" + ${_target_directory}/$/qtloader.js + ) + add_custom_command( + TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg" + ${_target_directory}/$/qtlogo.svg + ) + else() + configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtloader.js" + ${_target_directory}/qtloader.js COPYONLY) + configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg" + ${_target_directory}/qtlogo.svg COPYONLY) + endif() endif() - endif() if(QT_FEATURE_thread) diff --git a/tests/auto/wasm/selenium/CMakeLists.txt b/tests/auto/wasm/selenium/CMakeLists.txt index 445030878e9..4a26df885ea 100644 --- a/tests/auto/wasm/selenium/CMakeLists.txt +++ b/tests/auto/wasm/selenium/CMakeLists.txt @@ -9,6 +9,7 @@ endif() qt_internal_add_test(tst_qwasmwindow_harness MANUAL NO_BATCH + NO_WASM_DEFAULT_FILES SOURCES tst_qwasmwindow_harness.cpp LIBRARIES @@ -50,8 +51,8 @@ qt_internal_create_test_script(NAME tst_qwasmwindow_harness add_custom_command( TARGET tst_qwasmwindow_harness POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/tst_qwasmwindow_harness.html - ${CMAKE_CURRENT_BINARY_DIR}/tst_qwasmwindow_harness.html + ${CMAKE_CURRENT_SOURCE_DIR}/tst_qwasmwindow_harness_run.html + ${CMAKE_CURRENT_BINARY_DIR}/tst_qwasmwindow_harness_run.html ) add_custom_command( diff --git a/tests/auto/wasm/selenium/qwasmwindow.py b/tests/auto/wasm/selenium/qwasmwindow.py index 3d70f742034..8e275a76622 100644 --- a/tests/auto/wasm/selenium/qwasmwindow.py +++ b/tests/auto/wasm/selenium/qwasmwindow.py @@ -21,7 +21,7 @@ class WidgetTestCase(unittest.TestCase): def setUp(self): self._driver = Chrome(service=ChromeService(ChromeDriverManager().install())) self._driver.get( - 'http://localhost:8001/tst_qwasmwindow_harness.html') + 'http://localhost:8001/tst_qwasmwindow_harness_run.html') self._test_sandbox_element = WebDriverWait(self._driver, 30).until( presence_of_element_located((By.ID, 'test-sandbox')) ) diff --git a/tests/auto/wasm/selenium/tst_qwasmwindow_harness.html b/tests/auto/wasm/selenium/tst_qwasmwindow_harness_run.html similarity index 100% rename from tests/auto/wasm/selenium/tst_qwasmwindow_harness.html rename to tests/auto/wasm/selenium/tst_qwasmwindow_harness_run.html