modules/qt: Allow generated sources for arguemnts to compile_moc

pull/9012/head
Dylan Baker 3 years ago
parent 35dbf7e6d4
commit 965fcf2883
  1. 9
      docs/markdown/_include_qt_base.md
  2. 22
      mesonbuild/modules/qt.py

@ -35,9 +35,12 @@ Compiles Qt's moc files (.moc) into header and/or source files. At least one of
the keyword arguments `headers` and `sources` must be provided.
It takes no positional arguments, and the following keyword arguments:
- `sources` (File | string)[]: A list of sources to be transpiled into .moc
files for manual inclusion.
- `headers` (File | string)[]: A list of headers to be transpiled into .cpp files
- `sources` (File | string | custom_target | custom_target index | generator_output)[]:
A list of sources to be transpiled into .moc files for manual inclusion.
*New in 0.60.0*: support for custom_target, custom_target_index, and generator_output.
- `headers` (File | string | custom_target | custom_target index | generator_output)[]:
A list of headers to be transpiled into .cpp files
*New in 0.60.0*: support for custom_target, custom_target_index, and generator_output.
- `extra_args` string[]: Extra arguments to pass directly to `qt-moc`
- `method` string: The method to use to detect qt, see `dependency()` for more
information.

@ -60,8 +60,8 @@ if T.TYPE_CHECKING:
"""Keyword arguments for the Moc Compiler method."""
sources: T.List[T.Union[FileOrString, build.CustomTarget]]
headers: T.List[T.Union[FileOrString, build.CustomTarget]]
sources: T.Sequence[T.Union[FileOrString, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
headers: T.Sequence[T.Union[FileOrString, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
extra_args: T.List[str]
method: str
include_directories: T.List[T.Union[str, build.IncludeDirs]]
@ -366,14 +366,28 @@ class QtBaseModule(ExtensionModule):
@noPosargs
@typed_kwargs(
'qt.compile_moc',
KwargInfo('sources', ContainerTypeInfo(list, (File, str, build.CustomTarget)), listify=True, default=[]),
KwargInfo('headers', ContainerTypeInfo(list, (File, str, build.CustomTarget)), listify=True, default=[]),
KwargInfo(
'sources',
ContainerTypeInfo(list, (File, str, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)),
listify=True,
default=[],
),
KwargInfo(
'headers',
ContainerTypeInfo(list, (File, str, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)),
listify=True,
default=[]
),
KwargInfo('extra_args', ContainerTypeInfo(list, str), listify=True, default=[]),
KwargInfo('method', str, default='auto'),
KwargInfo('include_directories', ContainerTypeInfo(list, (build.IncludeDirs, str)), listify=True, default=[]),
KwargInfo('dependencies', ContainerTypeInfo(list, (Dependency, ExternalLibrary)), listify=True, default=[]),
)
def compile_moc(self, state: 'ModuleState', args: T.Tuple, kwargs: 'MocCompilerKwArgs') -> ModuleReturnValue:
if any(isinstance(s, (build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)) for s in kwargs['headers']):
FeatureNew.single_use('qt.compile_moc: custom_target or generator for "headers" keyword argument', '0.60.0', state.subproject)
if any(isinstance(s, (build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)) for s in kwargs['sources']):
FeatureNew.single_use('qt.compile_moc: custom_target or generator for "sources" keyword argument', '0.60.0', state.subproject)
out = self._compile_moc_impl(state, kwargs)
return ModuleReturnValue(out, [out])

Loading…
Cancel
Save