From cb5fbbde27a4cf217046085fc493ae076ba9bb02 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 18 Sep 2019 09:27:22 +0200 Subject: [PATCH] Fix up documentation integration placeholder In the future need will need to continue to tie qdoc runs still to targets, just like with qmake. This change prepares us for that by ensuring that add_docs takes two parameters and that any re-generated CMakeLists.txt from now on gets it right. Change-Id: Id0256dc1e2f2f59f3b4e4ca98f0d10d025d189fb Reviewed-by: Alexandru Croitor --- cmake/QtBuild.cmake | 12 +++++++++++- util/cmake/pro2cmake.py | 39 ++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 949d0d979c3..425bdd82707 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2779,7 +2779,17 @@ function(qt_compute_injection_forwarding_header target) endfunction() -function(add_qt_docs qdocFile) +function(add_qt_docs) + if(${ARGC} EQUAL 1) + # Function called from old generated CMakeLists.txt that was missing the target parameter + return() + endif() + if(NOT ${ARGC} EQUAL 2) + message(FATAL_ERROR "add_qt_docs called with the wrong number of arguments. Should be add_qt_docs(target path_to_project.qdocconf).") + return() + endif() + set(target ${ARGV0}) + set(doc_project ${ARGV1}) # TODO endfunction() diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index cea4e4259c4..c4e383c10d4 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -2080,7 +2080,7 @@ def write_main_part(cm_fh: typing.IO[str], name: str, typename: str, cm_fh.write(ignored_keys_report) def write_module(cm_fh: typing.IO[str], scope: Scope, *, - indent: int = 0) -> None: + indent: int = 0) -> str: module_name = scope.TARGET if not module_name.startswith('Qt'): print('XXXXXX Module name {} does not start with Qt!'.format(module_name)) @@ -2112,7 +2112,8 @@ def write_module(cm_fh: typing.IO[str], scope: Scope, *, if module_plugin_types: extra.append('PLUGIN_TYPES {}'.format(" ".join(module_plugin_types))) - write_main_part(cm_fh, module_name[2:], 'Module', 'add_qt_module', scope, + target_name = module_name[2:] + write_main_part(cm_fh, target_name, 'Module', 'add_qt_module', scope, extra_lines=extra, indent=indent, known_libraries={}, extra_keys=[]) @@ -2121,9 +2122,11 @@ def write_module(cm_fh: typing.IO[str], scope: Scope, *, cm_fh.write('\n\n{}qt_create_tracepoints({} {})\n' .format(spaces(indent), module_name[2:], ' '.join(tracepoints))) + return target_name + def write_tool(cm_fh: typing.IO[str], scope: Scope, *, - indent: int = 0) -> None: + indent: int = 0) -> str: tool_name = scope.TARGET extra = ['BOOTSTRAP'] if 'force_bootstrap' in scope.get('CONFIG') else [] @@ -2132,9 +2135,11 @@ def write_tool(cm_fh: typing.IO[str], scope: Scope, *, indent=indent, known_libraries={'Qt::Core', }, extra_lines=extra, extra_keys=['CONFIG']) + return tool_name + def write_test(cm_fh: typing.IO[str], scope: Scope, - gui: bool = False, *, indent: int = 0) -> None: + gui: bool = False, *, indent: int = 0) -> str: test_name = scope.TARGET assert test_name @@ -2154,6 +2159,8 @@ def write_test(cm_fh: typing.IO[str], scope: Scope, indent=indent, known_libraries=libraries, extra_lines=extra, extra_keys=[]) + return test_name + def write_binary(cm_fh: typing.IO[str], scope: Scope, gui: bool = False, *, indent: int = 0) -> None: @@ -2180,6 +2187,8 @@ def write_binary(cm_fh: typing.IO[str], scope: Scope, extra_lines=extra, indent=indent, known_libraries={'Qt::Core', }, extra_keys=['target.path', 'INSTALLS']) + return binary_name + def write_find_package_section(cm_fh: typing.IO[str], public_libs: typing.List[str], @@ -2202,7 +2211,7 @@ def write_find_package_section(cm_fh: typing.IO[str], def write_example(cm_fh: typing.IO[str], scope: Scope, - gui: bool = False, *, indent: int = 0) -> None: + gui: bool = False, *, indent: int = 0) -> str: binary_name = scope.TARGET assert binary_name @@ -2242,8 +2251,10 @@ def write_example(cm_fh: typing.IO[str], scope: Scope, ' LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"\n' + ')\n') + return binary_name -def write_plugin(cm_fh, scope, *, indent: int = 0): + +def write_plugin(cm_fh, scope, *, indent: int = 0) -> str: plugin_name = scope.TARGET assert plugin_name @@ -2264,6 +2275,7 @@ def write_plugin(cm_fh, scope, *, indent: int = 0): write_main_part(cm_fh, plugin_name, 'Plugin', plugin_function_name, scope, indent=indent, extra_lines=extra, known_libraries={}, extra_keys=[]) + return plugin_name def write_qml_plugin(cm_fh: typing.IO[str], @@ -2348,34 +2360,35 @@ def handle_app_or_lib(scope: Scope, cm_fh: typing.IO[str], *, is_lib = scope.TEMPLATE == 'lib' is_qml_plugin = any('qml_plugin' == s for s in scope.get('_LOADED')) is_plugin = any('qt_plugin' == s for s in scope.get('_LOADED')) or is_qml_plugin or 'plugin' in config + target = "" if is_plugin: assert not is_example - write_plugin(cm_fh, scope, indent=indent) + target = write_plugin(cm_fh, scope, indent=indent) elif is_lib or 'qt_module' in scope.get('_LOADED'): assert not is_example - write_module(cm_fh, scope, indent=indent) + target = write_module(cm_fh, scope, indent=indent) elif 'qt_tool' in scope.get('_LOADED'): assert not is_example - write_tool(cm_fh, scope, indent=indent) + target = write_tool(cm_fh, scope, indent=indent) else: gui = all(val not in config for val in ['console', 'cmdline']) if 'testcase' in config \ or 'testlib' in config \ or 'qmltestcase' in config: assert not is_example - write_test(cm_fh, scope, gui, indent=indent) + target = write_test(cm_fh, scope, gui, indent=indent) else: if is_example: - write_example(cm_fh, scope, gui, indent=indent) + target = write_example(cm_fh, scope, gui, indent=indent) else: - write_binary(cm_fh, scope, gui, indent=indent) + target = write_binary(cm_fh, scope, gui, indent=indent) ind = spaces(indent) write_source_file_list(cm_fh, scope, '', ['QMAKE_DOCS',], indent, - header = 'add_qt_docs(\n', + header = f"add_qt_docs({target},\n", footer = ')\n')