aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2024-04-10 19:08:36 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2024-05-10 17:08:30 +0200
commita3a8e3421e7d8313c1806c0490db5609c884f3b3 (patch)
tree93fff7b86e1a79bf666c6c3e2df92db4154f9948
parent9eae3144040cafb3173ef922f96b7d3dc5526633 (diff)
Fix the broken semicolon separated list arguments for configure
When evaluating the arguments from the config.tl.opt file we need to consider that arguments may contain the escaped semicolons for the list arguments. The escaped semicolons '\;' needs to be converted to a CMake brace escaped sequence to make sure that semicolon persist when running the command. Fixes: QTBUG-124265 Change-Id: I051f856b43f75b0bac17ae13bd8c7de540f8c794 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--cmake/QtIRCommandLineHelpers.cmake1
-rw-r--r--cmake/QtIRHelpers.cmake2
-rw-r--r--cmake/QtIRProcessHelpers.cmake24
3 files changed, 24 insertions, 3 deletions
diff --git a/cmake/QtIRCommandLineHelpers.cmake b/cmake/QtIRCommandLineHelpers.cmake
index 465a994b..65c5d6aa 100644
--- a/cmake/QtIRCommandLineHelpers.cmake
+++ b/cmake/QtIRCommandLineHelpers.cmake
@@ -244,6 +244,7 @@ endfunction()
# Reads the command line arguments from the optfile_path.
function(qt_ir_get_raw_args_from_optfile optfile_path out_var)
file(STRINGS "${optfile_path}" args)
+ qt_ir_escape_semicolons(args "${args}")
set(${out_var} "${args}" PARENT_SCOPE)
endfunction()
diff --git a/cmake/QtIRHelpers.cmake b/cmake/QtIRHelpers.cmake
index 9f372932..8e2af7f8 100644
--- a/cmake/QtIRHelpers.cmake
+++ b/cmake/QtIRHelpers.cmake
@@ -225,7 +225,7 @@ endfunction()
# to run the perly script manually.
function(qt_ir_show_error_how_to_run_perl opt_file unsupported_option_name)
qt_ir_get_raw_args_from_optfile("${opt_file}" args)
- string(REPLACE ";" " " args "${args}")
+ qt_ir_prettify_command_args(args "${args}")
set(perl_cmd "perl ./init-repository.pl ${args}")
diff --git a/cmake/QtIRProcessHelpers.cmake b/cmake/QtIRProcessHelpers.cmake
index db7bf2cb..cddd2736 100644
--- a/cmake/QtIRProcessHelpers.cmake
+++ b/cmake/QtIRProcessHelpers.cmake
@@ -53,10 +53,11 @@ function(qt_ir_execute_process)
endif()
endif()
- string(REPLACE ";" " " command_args_string "${arg_COMMAND_ARGS}")
+ qt_ir_prettify_command_args(command_args_string "${arg_COMMAND_ARGS}")
message("+ ${command_args_string}${working_dir_message}")
endif()
+ qt_ir_unescape_semicolons(arg_COMMAND_ARGS "${arg_COMMAND_ARGS}")
execute_process(
COMMAND ${arg_COMMAND_ARGS}
${working_dir}
@@ -76,6 +77,25 @@ function(qt_ir_execute_process)
endif()
endfunction()
+# Guards the escaped semicolon sequences with square brackets.
+function(qt_ir_escape_semicolons out_var input_string)
+ string(REPLACE "\;" "[[;]]" ${out_var} "${input_string}")
+ set(${out_var} "${${out_var}}" PARENT_SCOPE)
+endfunction()
+
+# Removes the square bracket guards around semicolons and escape them.
+function(qt_ir_unescape_semicolons out_var input_string)
+ string(REPLACE "[[;]]" "\;" ${out_var} "${input_string}")
+ set(${out_var} "${${out_var}}" PARENT_SCOPE)
+endfunction()
+
+# Converts the command line arguments to a nice bash runnable string
+function(qt_ir_prettify_command_args output args)
+ list(JOIN args " " ${output})
+ qt_ir_unescape_semicolons(${output} "${${output}}")
+ set(${output} "${${output}}" PARENT_SCOPE)
+endfunction()
+
# A higher level execute_process wrapper that can be used to execute a single command
# that is a bit more opinionated and expects options related to init-repository
# functionality.
@@ -142,7 +162,7 @@ function(qt_ir_execute_process_and_log_and_handle_error)
set(error_message "${arg_ERROR_MESSAGE}\n")
endif()
- string(REPLACE ";" " " cmd "${arg_COMMAND_ARGS}")
+ qt_ir_prettify_command_args(cmd "${arg_COMMAND_ARGS}")
string(APPEND error_message "${cmd} exited with status: ${proc_result}\n")
if(proc_output)
string(APPEND error_message "stdout: ${proc_output}\n")