diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-04-26 18:02:09 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-04-29 16:22:15 +0200 |
commit | d6fc3c0f4f98ef495ffc1d314103c0314fae1d98 (patch) | |
tree | f47b16c9cdaff9d3161386bac881e003b54acb40 | |
parent | 64512eafbae4e6888708b4b20e306d1f39281ce3 (diff) |
CMake: Normalize submodule names by stripping tqtc- prefixes
In tqtc repos, the dependencies.yaml files may point to tqtc- prefixed
repos, which can lead to build failures when doing a top-level build
and the local repo directory names have no tqtc- prefix.
This is the case both in the CI, and when using init-repository or
git submodule init --recursive, because qt5.git specifies the 'path'
key for each submodule to not contain any tqtc- prefix.
Normalize the repo names by removing the tqtc- prefix when doing
dependency resolution for CMake add_subdirectory calls, if such a
submodule name does not exist on-disk.
The normalization is conditional, to allow inclusion of repos that
don't have a non-tqtc mirror.
qt_internal_sync_to and the other git related operations
are currently broken (both before and after this change) when
used in conjunction with tqtc- repos and is non-trivial to fix.
The first problem is the assumption of using the 'origin' remote,
which will likely be an open-source repo that doesn't contain
any tqtc repos.
The second problem is that we would need to agree upon requiring
2 remotes, one open source and one tqtc one, to reliably choose
where to clone / fetch from, as well as determining whether
the checked out repo name needs to have a tqtc- prefix
(by checking whether the repo does not exist in the open source
remote for commercial only repos).
Alternatively we could hard code a list of known open source repos,
and anything not in the list will have its tqtc- prefix kept, but we
still need to know which remote to use.
As a drive-by, adjusted some of the shown messages for better
readability and easier grepping.
Fixes: QTBUG-102883
Change-Id: I6806b119dd32b14dc0d9711dc829bfc5130d1e6f
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 30068f2223b112650a1fb61ca6fd3b42cb26fcd3)
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | cmake/QtTopLevelHelpers.cmake | 55 |
2 files changed, 52 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b1afb2f5..88e440a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ qt_internal_sort_module_dependencies("${QT_BUILD_SUBMODULES}" QT_BUILD_SUBMODULE foreach(module IN LISTS QT_BUILD_SUBMODULES) # Check for unmet dependencies if(NOT DEFINED BUILD_${module} OR BUILD_${module}) - message(NOTICE "Checking dependencies of '${module}'") + message(NOTICE "Checking dependencies of submodule '${module}'") get_property(required_deps GLOBAL PROPERTY QT_REQUIRED_DEPS_FOR_${module}) get_property(dependencies GLOBAL PROPERTY QT_DEPS_FOR_${module}) foreach(dep IN LISTS dependencies) @@ -93,7 +93,7 @@ foreach(module IN LISTS QT_BUILD_SUBMODULES) endforeach() foreach(module IN LISTS QT_BUILD_SUBMODULES) - message(NOTICE "Configuring '${module}'") + message(NOTICE "Configuring submodule '${module}'") ecm_optional_add_subdirectory("${module}") if(module STREQUAL "qtbase") diff --git a/cmake/QtTopLevelHelpers.cmake b/cmake/QtTopLevelHelpers.cmake index 1288fdac..ce787cc9 100644 --- a/cmake/QtTopLevelHelpers.cmake +++ b/cmake/QtTopLevelHelpers.cmake @@ -47,7 +47,8 @@ function(qt_internal_parse_dependencies depends_file out_dependencies) string(TOUPPER "${CMAKE_MATCH_1}" required) endif() endforeach() - message(DEBUG "qt_internal_parse_dependencies for ${depends_file}: ${dependencies} ${revisions}") + message(DEBUG + "qt_internal_parse_dependencies for ${depends_file}\n dependencies: ${dependencies}") set(${out_dependencies} "${dependencies}" PARENT_SCOPE) endfunction() @@ -58,6 +59,24 @@ macro(qt_internal_resolve_module_dependencies_set_skipped value) endif() endmacro() +# Strips tqtc- prefix from a repo name. +function(qt_internal_normalize_repo_name repo_name out_var) + string(REGEX REPLACE "^tqtc-" "" normalized "${repo_name}") + set(${out_var} "${normalized}" PARENT_SCOPE) +endfunction() + +# Checks if a directory with the given repo name exists in the current +# source / working directory. If it doesn't, it strips the tqtc- prefix. +function(qt_internal_use_normalized_repo_name_if_needed repo_name out_var) + set(base_dir "${CMAKE_CURRENT_SOURCE_DIR}") + set(repo_dir "${base_dir}/${repo_name}") + if(NOT IS_DIRECTORY "${repo_dir}") + qt_internal_normalize_repo_name("${repo_name}" repo_name) + endif() + set(${out_var} "${repo_name}" PARENT_SCOPE) +endfunction() + + # Resolve the dependencies of the given module. # "Module" in the sense of Qt repository. # @@ -89,8 +108,11 @@ endmacro() # # SKIPPED_VAR is an output variable name that is set to TRUE if the module was skipped, to FALSE # otherwise. +# +# NORMALIZE_REPO_NAME_IF_NEEDED Will remove 'tqtc-' from the beginning of submodule dependencies +# if a tqtc- named directory does not exist. function(qt_internal_resolve_module_dependencies module out_ordered out_revisions) - set(options IN_RECURSION) + set(options IN_RECURSION NORMALIZE_REPO_NAME_IF_NEEDED) set(oneValueArgs REVISION SKIPPED_VAR) set(multiValueArgs PARSED_DEPENDENCIES) cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -138,6 +160,12 @@ function(qt_internal_resolve_module_dependencies module out_ordered out_revision message(FATAL_ERROR "Internal Error: wrong dependency format ${dependency}") endif() + set(normalize_arg "") + if(arg_NORMALIZE_REPO_NAME_IF_NEEDED) + qt_internal_use_normalized_repo_name_if_needed("${dependency}" dependency) + set(normalize_arg "NORMALIZE_REPO_NAME_IF_NEEDED") + endif() + set_property(GLOBAL APPEND PROPERTY QT_DEPS_FOR_${module} ${dependency}) if(required) set_property(GLOBAL APPEND PROPERTY QT_REQUIRED_DEPS_FOR_${module} ${dependency}) @@ -146,7 +174,9 @@ function(qt_internal_resolve_module_dependencies module out_ordered out_revision qt_internal_resolve_module_dependencies(${dependency} dep_ordered dep_revisions REVISION "${revision}" SKIPPED_VAR skipped - IN_RECURSION) + IN_RECURSION + ${normalize_arg} + ) if(NOT skipped) list(APPEND ordered ${dep_ordered}) list(APPEND revisions ${dep_revisions}) @@ -179,13 +209,17 @@ function(qt_internal_sort_module_dependencies modules out_all_ordered) endforeach() qt_internal_resolve_module_dependencies(all_selected_repos ordered unused_revisions - PARSED_DEPENDENCIES ${all_selected_repos_as_parsed_dependencies}) + PARSED_DEPENDENCIES ${all_selected_repos_as_parsed_dependencies} + NORMALIZE_REPO_NAME_IF_NEEDED + ) # Drop "all_selected_repos" from the output. It depends on all selected repos, thus it must be # the last element in the topologically sorted list. list(REMOVE_AT ordered -1) - message(DEBUG "qt_internal_parse_dependencies sorted ${modules}: ${ordered}") + message(DEBUG + "qt_internal_sort_module_dependencies + input modules: ${modules}\n topo-sorted: ${ordered}") set(${out_all_ordered} "${ordered}" PARENT_SCOPE) endfunction() @@ -322,6 +356,17 @@ function(qt_internal_sync_to module) endif() qt_internal_checkout("${module}" "${revision}") + qt_internal_resolve_module_dependencies(${module} initial_dependencies initial_revisions) + if(initial_dependencies) + foreach(dependency ${initial_dependencies}) + if(dependency MATCHES "^tqtc-") + message(WARNING + "Handling of tqtc- repos will likely fail. Fixing this is non-trivial.") + break() + endif() + endforeach() + endif() + set(revision "") set(checkedout "1") # Load all dependencies for $module, then iterate over the dependencies in reverse order, |