CMake: Fix dbus and vk headers to be excluded from doc generation

Before this change, if someone called ninja Gui_generate_docs, it
would implicitly depend on sync_all_public_headers -> Gui_sync_headers
which would generate dbus headers.

This caused trouble with the new 'build doc tools from
qttools/dev/HEAD' approach, because an older pre-built dbus tool might
be passed a newer option when integrating a qtbase change that passes
the new option.

To avoid that, we now filter out the dbus headers from the list of
headers that should be processed by syncqt when building a
documentation target.

We do the same for the qvkgen generated headers.

This also removes the dependency on the ${target}_sync_headers target,
which means there is a potential issue when someone manually calls
`ninja sync_all_public_headers Gui_sync_headers` or something like it,
which would spawn two syncqt processes that access the same files
concurrently. This is an edge case that should not happen, but if it
ends up happening, we will have to implement some kind of lock file
mechanism.

Pick-to: 6.8 6.9
Fixes: QTBUG-134672
Task-number: QTBUG-128730
Change-Id: I9061f9495e2faa77744f5f5c0de8fedd362ba228
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2025-03-20 15:39:02 +01:00
parent 4c9a4ecd35
commit e7834e90f3
4 changed files with 37 additions and 5 deletions

View File

@ -79,4 +79,9 @@ function(qt_create_qdbusxml2cpp_command target infile)
"${header_file_full}"
"${source_file_full}"
)
set_source_files_properties(
"${header_file_full}"
"${source_file_full}"
PROPERTIES
_qt_syncqt_exclude_from_docs TRUE)
endfunction()

View File

@ -1196,8 +1196,11 @@ function(qt_finalize_module target)
# property which supposed to be updated inside every qt_internal_install_module_headers
# call.
qt_internal_add_headersclean_target(${target} "${module_headers_public}")
qt_internal_target_sync_headers(${target} "${module_headers_all}"
"${module_headers_generated}")
qt_internal_target_sync_headers(${target}
"${module_headers_all}"
"${module_headers_generated}"
"${module_headers_exclude_from_docs}"
)
get_target_property(module_depends_header ${target} _qt_module_depends_header)
qt_internal_install_module_headers(${target}
PUBLIC ${module_headers_public} "${module_depends_header}"
@ -1627,6 +1630,7 @@ endfunction()
function(qt_internal_collect_module_headers out_var target)
set(${out_var}_public "")
set(${out_var}_private "")
set(${out_var}_exclude_from_docs "")
set(${out_var}_qpa "")
set(${out_var}_rhi "")
set(${out_var}_ssg "")
@ -1698,6 +1702,12 @@ function(qt_internal_collect_module_headers out_var target)
set(is_3rdparty_header FALSE)
endif()
list(APPEND ${out_var}_all "${file_path}")
get_source_file_property(exclude_from_docs "${file_path}" _qt_syncqt_exclude_from_docs)
if(exclude_from_docs)
list(APPEND ${out_var}_exclude_from_docs "${file_path}")
endif()
if(qpa_filter AND file_name MATCHES "${qpa_filter}")
list(APPEND ${out_var}_qpa "${file_path}")
elseif(rhi_filter AND file_name MATCHES "${rhi_filter}")
@ -1740,6 +1750,7 @@ function(qt_internal_collect_module_headers out_var target)
endforeach()
set(${out_var}_all "${${out_var}_all}" PARENT_SCOPE)
set(${out_var}_generated "${${out_var}_generated}" PARENT_SCOPE)
set(${out_var}_exclude_from_docs "${${out_var}_exclude_from_docs}" PARENT_SCOPE)
if(has_header_types_properties)
set_target_properties(${target} PROPERTIES ${has_header_types_properties})

View File

@ -6,7 +6,11 @@
# QT_REPO_PUBLIC_NAMESPACE_REGEX cache variable, that can be set by repository in .cmake.conf file.
# The variable tells the syncqt program, what namespaces are treated as public. Symbols in public
# namespaces are considered when generating CaMeL case header files.
function(qt_internal_target_sync_headers target module_headers module_headers_generated)
function(qt_internal_target_sync_headers target
module_headers
module_headers_generated
module_headers_exclude_from_docs
)
if(NOT TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::syncqt)
message(FATAL_ERROR "${QT_CMAKE_EXPORT_NAMESPACE}::syncqt is not a target.")
endif()
@ -146,6 +150,11 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
list(FILTER module_headers EXCLUDE REGEX
"(.+/(ui_)[^/]+\\.h|${CMAKE_CURRENT_SOURCE_DIR}(/.+)?/doc/+\\.h)")
# Filter out all headers that should be excluded from documentation generation.
# Documentation generation shouldn't depend on headers like the dbus-generated ones.
set(module_headers_for_docs "${module_headers}")
list(REMOVE_ITEM module_headers_for_docs ${module_headers_exclude_from_docs})
set(syncqt_staging_dir "${module_build_interface_include_dir}/.syncqt_staging")
set(syncqt_args "${common_syncqt_arguments}")
@ -225,10 +234,16 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
"@${syncqt_all_args_rsp}"
${external_headers_dir_copy_cmd}
DEPENDS
${module_headers}
# Note, we don't depend anymore on ${target}_sync_headers so that we don't bring
# in the headers that are usually excluded from docs.
# This means if someone manually calls
# `ninja sync_all_public_headers Gui_sync_headers` it will cause havoc due to two
# syncqt calls accessing the same files concurrently. This is an edge case that should
# not happen, but it ends up happening, we will have to implement some kind of lock
# file mechanism.
${module_headers_for_docs}
${syncqt_all_args_rsp}
${QT_CMAKE_EXPORT_NAMESPACE}::syncqt
${target}_sync_headers
VERBATIM
)

View File

@ -1001,6 +1001,7 @@ add_custom_command(
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM
)
set_source_files_properties(${vulkan_fun_outputs} PROPERTIES _qt_syncqt_exclude_from_docs TRUE)
qt_internal_extend_target(Gui CONDITION WASM
SOURCES