diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-06-01 14:11:13 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-06-15 12:35:15 -0700 |
commit | fcdb0f9879f134e1113c1a1c6bddb4fcac323d4c (patch) | |
tree | 2c77eebab878d4ee5d82c2250aee42d4a2e112c6 | |
parent | ed06ae3db1ee56053663a812bdcc665c92e44cc6 (diff) | |
download | meson-fcdb0f9879f134e1113c1a1c6bddb4fcac323d4c.zip meson-fcdb0f9879f134e1113c1a1c6bddb4fcac323d4c.tar.gz meson-fcdb0f9879f134e1113c1a1c6bddb4fcac323d4c.tar.bz2 |
modules/qt: Add a compile_ui method
Which is the same functionality split out of preprocess
-rw-r--r-- | mesonbuild/modules/qt.py | 33 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/meson.build | 3 |
2 files changed, 35 insertions, 1 deletions
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index d25c127..e4d2f5f 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -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): diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build index ea5bc8d..b6f244a 100644 --- a/test cases/frameworks/4 qt/meson.build +++ b/test cases/frameworks/4 qt/meson.build @@ -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 = [] |