Add TRY_RUN_FLAGS argument to customize the TRY_RUN command

Some of our tools don't have the `-h`, or `-v` flag, or it could be
that the `-v` flag also prints the entire `--help` as well, e.g.,
`androiddeployqt`. When running in Jenkins, this may lead to a message
box being shown and consequently stopping the build. By customizing the
flag per tool, and limiting the TRY_RUN to tools that support `-v` or
`--version`, we can avoid this.

Also removed TRY_RUN from `macdeployqt` which doesn't need it anyway.

Amend 41b32cd2c4706fa280fc779d5dec132ee9edf0f6

Fixes: QTBUG-114530
Change-Id: I78e3344d2553c0050c285ae86f2310bd373c6c57
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 69d74afd43adac796efb3ebb1f7e73da64010cb5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Amir Masoud Abdol 2023-06-13 16:37:49 +02:00 committed by Qt Cherry-pick Bot
parent 2e55a34c1c
commit 14a7096bda
11 changed files with 11 additions and 12 deletions

View File

@ -19,6 +19,9 @@
# On Windows, it creates a helper batch script that tests whether the tool can be executed
# successfully or not. If not, build halts and an error will be show, with tips on what
# might be cause, and how to fix it.
# TRY_RUN_FLAGS
# Command line flags that are going to be passed to the tool for testing its correctness.
# If no flags were given, we default to `-v`.
#
# One-value Arguments:
# EXTRA_CMAKE_FILES
@ -52,6 +55,7 @@ function(qt_internal_add_tool target_name)
TOOLS_TARGET
INSTALL_DIR
CORE_LIBRARY
TRY_RUN_FLAGS
${__default_target_info_args})
set(multi_value_keywords
EXTRA_CMAKE_FILES
@ -230,14 +234,17 @@ function(qt_internal_add_tool target_name)
endif()
if(arg_TRY_RUN AND WIN32)
_qt_internal_add_try_run_post_build(${target_name})
if(NOT arg_TRY_RUN_FLAGS)
set(arg_TRY_RUN_FLAGS "-v")
endif()
_qt_internal_add_try_run_post_build("${target_name}" "${arg_TRY_RUN_FLAGS}")
endif()
qt_enable_separate_debug_info(${target_name} "${install_dir}" QT_EXECUTABLE)
qt_internal_install_pdb_files(${target_name} "${install_dir}")
endfunction()
function(_qt_internal_add_try_run_post_build target)
function(_qt_internal_add_try_run_post_build target try_run_flags)
qt_internal_get_upper_case_main_cmake_configuration(main_cmake_configuration)
get_target_property(target_out_dir ${target}
RUNTIME_OUTPUT_DIRECTORY_${main_cmake_configuration})
@ -251,7 +258,7 @@ function(_qt_internal_add_try_run_post_build target)
qt_configure_file(OUTPUT "${try_run_scripts_path}"
CONTENT "@echo off
${target_out_dir}/${target}.exe -h > nul 2>&1
${target_out_dir}/${target}.exe ${try_run_flags} > nul 2>&1
if \"%errorlevel%\" == \"-1073741515\" (
echo

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name androiddeployqt)
qt_internal_add_tool(${target_name}
TRY_RUN
TARGET_DESCRIPTION "Qt Android Deployment Tool"
TOOLS_TARGET Core
USER_FACING

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name androidtestrunner)
qt_internal_add_tool(${target_name}
TRY_RUN
TARGET_DESCRIPTION "Qt Android Test Runner Tool"
TOOLS_TARGET Core
SOURCES

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name cmake_automoc_parser)
qt_internal_add_tool(${target_name}
TRY_RUN
CORE_LIBRARY Bootstrap
TARGET_DESCRIPTION "Qt CMake AUTOMOC Parser"
INSTALL_DIR "${INSTALL_LIBEXECDIR}"

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name macdeployqt)
qt_internal_add_tool(${target_name}
TRY_RUN
TOOLS_TARGET Core
USER_FACING
INSTALL_VERSIONED_LINK

View File

@ -8,6 +8,7 @@
qt_get_tool_target_name(target_name qdbuscpp2xml)
qt_internal_add_tool(${target_name}
TRY_RUN
TRY_RUN_FLAGS "-V"
TARGET_DESCRIPTION "Qt D-Bus C++ to XML Compiler"
TOOLS_TARGET DBus
SOURCES

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name qlalr)
qt_internal_add_tool(${target_name}
TRY_RUN
TARGET_DESCRIPTION "Qt Look Ahead LR Parser Generator"
INSTALL_DIR "${INSTALL_LIBEXECDIR}"
TOOLS_TARGET Core

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name qvkgen)
qt_internal_add_tool(${target_name}
TRY_RUN
TARGET_DESCRIPTION "Qt Vulkan Header Generator"
INSTALL_DIR "${INSTALL_LIBEXECDIR}"
TOOLS_TARGET Gui

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name tracegen)
qt_internal_add_tool(${target_name}
TRY_RUN
CORE_LIBRARY Bootstrap
INSTALL_DIR "${INSTALL_LIBEXECDIR}"
TOOLS_TARGET Core

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name tracepointgen)
qt_internal_add_tool(${target_name}
TRY_RUN
CORE_LIBRARY Bootstrap
INSTALL_DIR "${INSTALL_LIBEXECDIR}"
TOOLS_TARGET Core

View File

@ -7,7 +7,6 @@
qt_get_tool_target_name(target_name windeployqt)
qt_internal_add_tool(${target_name}
TRY_RUN
TOOLS_TARGET Core
USER_FACING
INSTALL_VERSIONED_LINK