Qt: Allow passing dependency objects to preprocess method (#3470, #3875)

pull/4055/merge
Alexey Rochev 6 years ago committed by Jussi Pakkanen
parent e7b25018c4
commit 862019e6de
  1. 25
      mesonbuild/modules/qt.py
  2. 10
      test cases/frameworks/4 qt/meson.build
  3. 8
      test cases/frameworks/4 qt/qtinterface.cpp

@ -16,7 +16,7 @@ import os
from .. import mlog
from .. import build
from ..mesonlib import MesonException, Popen_safe, extract_as_list, File
from ..dependencies import Qt4Dependency, Qt5Dependency
from ..dependencies import Dependency, Qt4Dependency, Qt5Dependency
import xml.etree.ElementTree as ET
from . import ModuleReturnValue, get_include_args
from ..interpreterbase import permittedKwargs, FeatureNewKwargs
@ -117,10 +117,10 @@ class QtBaseModule:
return []
@FeatureNewKwargs('qt.preprocess', '0.44.0', ['moc_extra_arguments'])
@permittedKwargs({'moc_headers', 'moc_sources', 'moc_extra_arguments', 'include_directories', 'ui_files', 'qresources', 'method'})
@permittedKwargs({'moc_headers', 'moc_sources', 'moc_extra_arguments', 'include_directories', 'dependencies', 'ui_files', 'qresources', 'method'})
def preprocess(self, state, args, kwargs):
rcc_files, ui_files, moc_headers, moc_sources, moc_extra_arguments, sources, include_directories \
= extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'moc_extra_arguments', 'sources', 'include_directories', pop = True)
rcc_files, ui_files, moc_headers, moc_sources, moc_extra_arguments, sources, include_directories, dependencies \
= extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'moc_extra_arguments', 'sources', 'include_directories', 'dependencies', pop = True)
sources += args[1:]
method = kwargs.get('method', 'auto')
self._detect_tools(state.environment, method)
@ -166,15 +166,28 @@ class QtBaseModule:
ui_output = ui_gen.process_files('Qt{} ui'.format(self.qt_version), ui_files, state)
sources.append(ui_output)
inc = get_include_args(include_dirs=include_directories)
compile_args = []
for dep in dependencies:
if hasattr(dep, 'held_object'):
dep = dep.held_object
if isinstance(dep, Dependency):
for arg in dep.get_compile_args():
if arg.startswith('-I') or arg.startswith('-D'):
compile_args.append(arg)
else:
raise MesonException('Argument is of an unacceptable type {!r}.\nMust be '
'either an external dependency (returned by find_library() or '
'dependency()) or an internal dependency (returned by '
'declare_dependency()).'.format(type(dep).__name__))
if len(moc_headers) > 0:
arguments = moc_extra_arguments + inc + ['@INPUT@', '-o', '@OUTPUT@']
arguments = moc_extra_arguments + inc + compile_args + ['@INPUT@', '-o', '@OUTPUT@']
moc_kwargs = {'output': 'moc_@BASENAME@.cpp',
'arguments': arguments}
moc_gen = build.Generator([self.moc], moc_kwargs)
moc_output = moc_gen.process_files('Qt{} moc header'.format(self.qt_version), moc_headers, state)
sources.append(moc_output)
if len(moc_sources) > 0:
arguments = moc_extra_arguments + inc + ['@INPUT@', '-o', '@OUTPUT@']
arguments = moc_extra_arguments + inc + compile_args + ['@INPUT@', '-o', '@OUTPUT@']
moc_kwargs = {'output': '@BASENAME@.moc',
'arguments': arguments}
moc_gen = build.Generator([self.moc], moc_kwargs)

@ -100,6 +100,16 @@ foreach qt : ['qt4', 'qt5']
plugin = library(qt + 'plugin', 'plugin/plugin.cpp', pluginpreprocess,
include_directories : plugin_includes,
dependencies : qtcore)
# implementing Qt interfaces requires passing Qt include paths to moc
qtinterfacepreprocess = qtmodule.preprocess(
moc_sources : 'qtinterface.cpp',
dependencies : qtdep
)
qtinterface = library(qt + 'qtinterface',
sources : ['qtinterface.cpp', qtinterfacepreprocess],
dependencies : qtdep)
if qt == 'qt5'
subdir('subfolder')
endif

@ -0,0 +1,8 @@
#include <QGraphicsLayout>
class Foo : public QGraphicsLayout
{
Q_INTERFACES(QGraphicsLayout)
};
#include "qtinterface.moc"
Loading…
Cancel
Save