From bcc7d3454063520ec2a8d3c7a579a696ae2cc069 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 23 Oct 2020 14:37:58 +0200 Subject: [PATCH] CMake: Provide a qt-internal-configure-tests script This is meant to be called by our CI instructions to build standalone tests of a Qt repository. Currently it just calls qt-cmake with -DQT_BUILD_STANDALONE_TESTS=ON, but it might contain more things in the future. The script also simplifies configuring standalone tests locally, due to not having to remember the name of the magical variable. Change our CI instructions to use the new script. Change-Id: I6bc02b4e94adc9d0d05fecb0fe70a561043271f1 Reviewed-by: Qt CI Bot Reviewed-by: Cristian Adam --- bin/qt-internal-configure-tests.in | 3 ++ cmake/QtWrapperScriptHelpers.cmake | 32 +++++++++++++++++++ .../call_cmake_for_standalone_tests.yaml | 4 +-- ...cmake_build_and_upload_test_artifacts.yaml | 4 +-- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 bin/qt-internal-configure-tests.in diff --git a/bin/qt-internal-configure-tests.in b/bin/qt-internal-configure-tests.in new file mode 100755 index 00000000000..396cda7bf8f --- /dev/null +++ b/bin/qt-internal-configure-tests.in @@ -0,0 +1,3 @@ +@script_os_prelude@ + +@qt_cmake_path@ @script_passed_args@ diff --git a/cmake/QtWrapperScriptHelpers.cmake b/cmake/QtWrapperScriptHelpers.cmake index bf8205c46a8..581fd3c6d86 100644 --- a/cmake/QtWrapperScriptHelpers.cmake +++ b/cmake/QtWrapperScriptHelpers.cmake @@ -108,4 +108,36 @@ function(qt_internal_create_wrapper_scripts) "${QT_BUILD_DIR}/${INSTALL_BINDIR}/${__qt_cmake_install_script_name}" @ONLY) qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/${__qt_cmake_install_script_name}" DESTINATION "${INSTALL_BINDIR}") + + qt_internal_create_qt_configure_tests_wrapper_script() +endfunction() + +function(qt_internal_create_qt_configure_tests_wrapper_script) + # Create a private wrapper script to configure and build all standalone tests. + # + # The script uses qt-cmake instead of qt-cmake-private on purpose. That's to ensure we build + # only one configuration of tests (e.g RelWithDebInfo only) when Qt is configured with more + # than one configuration (RelWithDebInfo;Debug). + # Meant to be used by our CI instructions. + # + # The script takes a path to the repo for which the standalone tests will be configured. + set(script_name "qt-internal-configure-tests") + set(qt_cmake_path + "${QT_STAGING_PREFIX}/${INSTALL_BINDIR}/qt-cmake") + + set(common_args "-DQT_BUILD_STANDALONE_TESTS=ON") + if(CMAKE_HOST_UNIX) + set(script_os_prelude "#!/bin/sh") + string(PREPEND qt_cmake_path "exec ") + set(script_passed_args "${common_args} \"$@\"") + else() + set(script_os_prelude "@echo off") + string(APPEND script_name ".bat") + string(APPEND qt_cmake_path ".bat") + set(script_passed_args "${common_args} %*") + endif() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-internal-configure-tests.in" + "${QT_BUILD_DIR}/${INSTALL_BINDIR}/${script_name}") + qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/${script_name}" + DESTINATION "${INSTALL_BINDIR}") endfunction() diff --git a/coin/instructions/call_cmake_for_standalone_tests.yaml b/coin/instructions/call_cmake_for_standalone_tests.yaml index 8414ee44a1b..501ab3abab1 100644 --- a/coin/instructions/call_cmake_for_standalone_tests.yaml +++ b/coin/instructions/call_cmake_for_standalone_tests.yaml @@ -1,7 +1,7 @@ type: Group instructions: - type: ExecuteCommand - command: "{{.Env.TESTS_ENV_PREFIX}} {{.Env.INSTALL_DIR_FOR_CMAKE_TESTS}}\\bin\\qt-cmake {{.Env.COIN_CMAKE_ARGS}}" + command: "{{.Env.TESTS_ENV_PREFIX}} {{.Env.INSTALL_DIR_FOR_CMAKE_TESTS}}\\bin\\qt-internal-configure-tests {{.Env.COIN_CMAKE_ARGS}}" executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution maxTimeInSeconds: 6000 maxTimeBetweenOutput: 1200 @@ -12,7 +12,7 @@ instructions: property: host.os equals_value: Windows - type: ExecuteCommand - command: "{{.Env.TESTS_ENV_PREFIX}} {{.Env.INSTALL_DIR_FOR_CMAKE_TESTS}}/bin/qt-cmake {{.Env.COIN_CMAKE_ARGS}}" + command: "{{.Env.TESTS_ENV_PREFIX}} {{.Env.INSTALL_DIR_FOR_CMAKE_TESTS}}/bin/qt-internal-configure-tests {{.Env.COIN_CMAKE_ARGS}}" executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution maxTimeInSeconds: 6000 maxTimeBetweenOutput: 1200 diff --git a/coin/instructions/cmake_build_and_upload_test_artifacts.yaml b/coin/instructions/cmake_build_and_upload_test_artifacts.yaml index 1ed88ff7d50..84077980b85 100644 --- a/coin/instructions/cmake_build_and_upload_test_artifacts.yaml +++ b/coin/instructions/cmake_build_and_upload_test_artifacts.yaml @@ -10,14 +10,14 @@ instructions: directory: "{{.BuildDir}}" - type: AppendToEnvironmentVariable variableName: COIN_CMAKE_ARGS - variableValue: " -DQT_BUILD_STANDALONE_TESTS=ON -DCMAKE_AUTOGEN_VERBOSE=ON -S {{.SourceDir}} -B ." + variableValue: " -DCMAKE_AUTOGEN_VERBOSE=ON -S {{.SourceDir}} -B ." disable_if: condition: runtime env_var: COIN_CMAKE_ARGS equals_value: null - type: EnvironmentVariable variableName: COIN_CMAKE_ARGS - variableValue: "-DQT_BUILD_STANDALONE_TESTS=ON -DCMAKE_AUTOGEN_VERBOSE=ON -S {{.SourceDir}} -B ." + variableValue: "-DCMAKE_AUTOGEN_VERBOSE=ON -S {{.SourceDir}} -B ." enable_if: condition: runtime env_var: COIN_CMAKE_ARGS