modules/qt: Add a compile_ui method

Which is the same functionality split out of preprocess
pull/8822/head
Dylan Baker 4 years ago
parent ed06ae3db1
commit fcdb0f9879
  1. 33
      mesonbuild/modules/qt.py
  2. 3
      test cases/frameworks/4 qt/meson.build

@ -46,6 +46,14 @@ if T.TYPE_CHECKING:
extra_args: T.List[str]
method: str
class UICompilerKwArgs(TypedDict):
"""Keyword arguments for the Ui Compiler method."""
sources: T.List[mesonlib.FileOrString]
extra_args: T.List[str]
method: str
class QtBaseModule(ExtensionModule):
tools_detected = False
@ -63,6 +71,7 @@ class QtBaseModule(ExtensionModule):
'preprocess': self.preprocess,
'compile_translations': self.compile_translations,
'compile_resources': self.compile_resources,
'compile_ui': self.compile_ui,
})
def compilers_detect(self, state, qt_dep: 'QtBaseDependency') -> None:
@ -269,6 +278,29 @@ class QtBaseModule(ExtensionModule):
return ModuleReturnValue(targets, [targets])
@FeatureNew('qt.compile_ui', '0.59.0')
@noPosargs
@typed_kwargs(
'qt.compile_ui',
KwargInfo('sources', ContainerTypeInfo(list, (File, str), allow_empty=False), listify=True, required=True),
KwargInfo('extra_args', ContainerTypeInfo(list, str), listify=True),
KwargInfo('method', str, default='auto')
)
def compile_ui(self, state: 'ModuleState', args: T.Tuple, kwargs: 'ResourceCompilerKwArgs') -> ModuleReturnValue:
"""Compile UI resources into cpp headers."""
self._detect_tools(state, kwargs['method'])
if not self.uic.found():
err_msg = ("{0} sources specified and couldn't find {1}, "
"please check your qt{2} installation")
raise MesonException(err_msg.format('UIC', f'uic-qt{self.qt_version}', self.qt_version))
ui_kwargs: T.Dict[str, T.Any] = { # TODO: if Generator was properly annotated…
'output': 'ui_@BASENAME@.h',
'arguments': kwargs['extra_args'] or [] + ['-o', '@OUTPUT@', '@INPUT@']}
# TODO: This generator isn't added to the generator list in the Interpreter
gen = build.Generator([self.uic], ui_kwargs)
out = gen.process_files(f'Qt{self.qt_version} ui', kwargs['sources'], state)
return ModuleReturnValue(out, [out]) # type: ignore
@FeatureNewKwargs('qt.preprocess', '0.49.0', ['uic_extra_arguments'])
@FeatureNewKwargs('qt.preprocess', '0.44.0', ['moc_extra_arguments'])
@ -305,6 +337,7 @@ class QtBaseModule(ExtensionModule):
ui_gen = build.Generator([self.uic], ui_kwargs)
ui_output = ui_gen.process_files(f'Qt{self.qt_version} ui', ui_files, state)
sources.append(ui_output)
inc = state.get_include_args(include_dirs=include_directories)
compile_args = []
for dep in unholder(dependencies):

@ -52,9 +52,10 @@ foreach qt : ['qt4', 'qt5', 'qt6']
prep = qtmodule.preprocess(
moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use.
ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol.
method : get_option('method')
)
# XML files that need to be compiled with the uic tol.
prep += qtmodule.compile_ui(sources : 'mainWindow.ui', method: get_option('method'))
# Resource file(s) for rcc compiler
extra_cpp_args = []

Loading…
Cancel
Save