init-repository: Fix passing relative path to --alternates

When using --alternates with a relative path, nested submodules
(e.g., qtdeclarative/tests/auto/qml/ecmascripttests/test262) failed
because the alternates path wasn't adjusted for the changed working
directory depth. The --alternates option worked correctly with absolute
paths.

Fix by converting the passed alternates path to an absolute path.

Pick-to: 6.8 6.10 6.11
Fixes: QTBUG-142712
Change-Id: Ief7a87768d9ff17bb2832ae363f573ecae58d5ee
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann
2025-12-11 16:35:20 +01:00
parent 740e232f16
commit d6918d7ac5
2 changed files with 15 additions and 1 deletions

View File

@@ -421,3 +421,17 @@ function(qt_ir_get_option_as_cmake_flag_option cli_name cmake_option_name out_va
endif()
set(${out_var} "${cmake_option}" PARENT_SCOPE)
endfunction()
# Get the value of a command line option as existing absolute path.
# Yield error if the path does not exist.
# Convert to absolute path if necessary.
function(qt_ir_get_option_as_existing_absolute_path name value)
qt_ir_get_option_value("${name}" path)
if(NOT EXISTS "${abspath}")
qt_ir_add_error("The path '${path}' passed with -${name} does not exist.")
endif()
if(NOT IS_ABSOLUTE "${path}")
get_filename_component(path "${path}" ABSOLUTE)
endif()
set("${value}" "${path}" PARENT_SCOPE)
endfunction()

View File

@@ -295,7 +295,7 @@ function(qt_ir_run_after_args_parsed top_level_src_path out_var_exit_reason)
"${working_directory}")
# Get some additional options to pass down.
qt_ir_get_option_value(alternates alternates)
qt_ir_get_option_as_existing_absolute_path(alternates alternates)
qt_ir_get_option_as_cmake_flag_option(branch "CHECKOUT_BRANCH" checkout_branch_option)
# The prefix for the cmake-style 'dictionary' that will be used by various functions.