Repository: mesonbuild/meson

Issue:
Regression: CustomTarget no longer allowed for qt.preprocess in 0.59
Hi!

A project I am working on currently fails to build with Meson 0.59 because output of the Qt DBus generator / Qt Remote Object compiler is passed to `qt.preprocess`, resulting in this new error:

```
ERROR: qt.preprocess keyword argument "moc_headers" contained a value of type "CustomTarget" but should have been one of: "File", "str"
```

This has worked fine before (Meson <= 0.58), and is probably a sideeffect of the Qt refactoring that has happened - maybe it's just a matter of allowing `CustomTarget` as a parameter, I will have a look at the code later :-)



Discussion:
It's probably pretty simple to fix, I'll have a look later today. So many of these interfaces are unfortunately badly documented as to what types they accept :/

Resolving patch:
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -52,7 +52,7 @@ class UICompilerKwArgs(TypedDict):
 
         """Keyword arguments for the Ui Compiler method."""
 
-        sources: T.List[FileOrString]
+        sources: T.Sequence[T.Union[FileOrString, build.CustomTarget]]
         extra_args: T.List[str]
         method: str
 
@@ -60,8 +60,8 @@ class MocCompilerKwArgs(TypedDict):
 
         """Keyword arguments for the Moc Compiler method."""
 
-        sources: T.List[FileOrString]
-        headers: T.List[FileOrString]
+        sources: T.List[T.Union[FileOrString, build.CustomTarget]]
+        headers: T.List[T.Union[FileOrString, build.CustomTarget]]
         extra_args: T.List[str]
         method: str
         include_directories: T.List[T.Union[str, build.IncludeDirs]]
@@ -70,10 +70,10 @@ class MocCompilerKwArgs(TypedDict):
     class PreprocessKwArgs(TypedDict):
 
         sources: T.List[FileOrString]
-        moc_sources: T.List[FileOrString]
-        moc_headers: T.List[FileOrString]
+        moc_sources: T.List[T.Union[FileOrString, build.CustomTarget]]
+        moc_headers: T.List[T.Union[FileOrString, build.CustomTarget]]
         qresources: T.List[FileOrString]
-        ui_files: T.List[FileOrString]
+        ui_files: T.List[T.Union[FileOrString, build.CustomTarget]]
         moc_extra_arguments: T.List[str]
         rcc_extra_arguments: T.List[str]
         uic_extra_arguments: T.List[str]
@@ -366,8 +366,8 @@ def _compile_ui_impl(self, state: 'ModuleState', kwargs: 'UICompilerKwArgs') ->
     @noPosargs
     @typed_kwargs(
         'qt.compile_moc',
-        KwargInfo('sources', ContainerTypeInfo(list, (File, str)), listify=True, default=[]),
-        KwargInfo('headers', ContainerTypeInfo(list, (File, str)), listify=True, default=[]),
+        KwargInfo('sources', ContainerTypeInfo(list, (File, str, build.CustomTarget)), listify=True, default=[]),
+        KwargInfo('headers', ContainerTypeInfo(list, (File, str, build.CustomTarget)), 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=[]),
@@ -414,9 +414,9 @@ def _compile_moc_impl(self, state: 'ModuleState', kwargs: 'MocCompilerKwArgs') -
         'qt.preprocess',
         KwargInfo('sources', ContainerTypeInfo(list, (File, str)), listify=True, default=[], deprecated='0.59.0'),
         KwargInfo('qresources', ContainerTypeInfo(list, (File, str)), listify=True, default=[]),
-        KwargInfo('ui_files', ContainerTypeInfo(list, (File, str)), listify=True, default=[]),
-        KwargInfo('moc_sources', ContainerTypeInfo(list, (File, str)), listify=True, default=[]),
-        KwargInfo('moc_headers', ContainerTypeInfo(list, (File, str)), listify=True, default=[]),
+        KwargInfo('ui_files', ContainerTypeInfo(list, (File, str, build.CustomTarget)), listify=True, default=[]),
+        KwargInfo('moc_sources', ContainerTypeInfo(list, (File, str, build.CustomTarget)), listify=True, default=[]),
+        KwargInfo('moc_headers', ContainerTypeInfo(list, (File, str, build.CustomTarget)), listify=True, default=[]),
         KwargInfo('moc_extra_arguments', ContainerTypeInfo(list, str), listify=True, default=[], since='0.44.0'),
         KwargInfo('rcc_extra_arguments', ContainerTypeInfo(list, str), listify=True, default=[], since='0.49.0'),
         KwargInfo('uic_extra_arguments', ContainerTypeInfo(list, str), listify=True, default=[], since='0.49.0'),


Test patch: