diff options
-rw-r--r-- | docs/markdown/Gnome-module.md | 4 | ||||
-rw-r--r-- | docs/markdown/Qt5-module.md | 8 | ||||
-rw-r--r-- | mesonbuild/backend/backends.py | 7 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 8 | ||||
-rw-r--r-- | mesonbuild/modules/qt4.py | 10 | ||||
-rw-r--r-- | mesonbuild/modules/qt5.py | 10 | ||||
-rwxr-xr-x | run_tests.py | 2 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/meson.build | 10 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/plugin/plugin.cpp | 7 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/plugin/plugin.h | 11 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/plugin/plugin.json | 3 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/pluginInterface/plugin_if.h | 21 | ||||
-rw-r--r-- | test cases/frameworks/7 gnome/gir/dep1/meson.build | 1 |
13 files changed, 87 insertions, 15 deletions
diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md index 99a9c8e..d87e108 100644 --- a/docs/markdown/Gnome-module.md +++ b/docs/markdown/Gnome-module.md @@ -81,6 +81,10 @@ tool so see its documentation for more information. * `includes`: list of gir names to be included, can also be a GirTarget +* `header`: *(Added 0.43.0)* name of main c header to include for the library, e.g. `glib.h` + +* `dependencies`: deps to use during introspection scanning + * `include_directories`: extra include paths to look for gir files * `install`: if true, install the generated files diff --git a/docs/markdown/Qt5-module.md b/docs/markdown/Qt5-module.md index 7082309..a8ad73d 100644 --- a/docs/markdown/Qt5-module.md +++ b/docs/markdown/Qt5-module.md @@ -5,17 +5,19 @@ tools and steps required for Qt. The module has one method. ## preprocess -This method takes four keyword arguments, `moc_headers`, +This method takes five keyword arguments, `moc_headers`, `moc_sources`, `ui_files` and `qresources` which define the files that -require preprocessing with `moc`, `uic` and `rcc`. It returns an +require preprocessing with `moc`, `uic` and `rcc` and 'include_directories' which might be needed by moc. It returns an opaque object that should be passed to a main build target. A simple example would look like this: ```meson qt5 = import('qt5') qt5_dep = dependency('qt5', modules: ['Core', 'Gui']) -moc_files = qt5.preprocess(moc_headers : 'myclass.h') +inc = include_directories('includes') +moc_files = qt5.preprocess(moc_headers : 'myclass.h', include_directories: inc) executable('myprog', 'main.cpp', 'myclass.cpp', moc_files, + include_directories: inc, dependencies : qt5_dep) ``` diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 960f2e2..61c5e90 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -162,8 +162,11 @@ class Backend: return os.path.relpath(target_dir, othert_dir) def get_target_source_dir(self, target): - dirname = os.path.join(self.build_to_src, self.get_target_dir(target)) - return dirname + # if target dir is empty, avoid extraneous trailing / from os.path.join() + target_dir = self.get_target_dir(target) + if target_dir: + return os.path.join(self.build_to_src, target_dir) + return self.build_to_src def get_target_private_dir(self, target): dirname = os.path.join(self.get_target_dir(target), target.get_basename() + target.type_suffix()) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index be29db9..1f813da 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -392,7 +392,7 @@ class GnomeModule(ExtensionModule): @permittedKwargs({'sources', 'nsversion', 'namespace', 'symbol_prefix', 'identifier_prefix', 'export_packages', 'includes', 'dependencies', 'link_with', 'include_directories', 'install', 'install_dir_gir', 'install_dir_typelib', 'extra_args', - 'packages', 'build_by_default'}) + 'packages', 'header', 'build_by_default'}) def generate_gir(self, state, args, kwargs): if len(args) != 1: raise MesonException('Gir takes one argument') @@ -427,6 +427,12 @@ class GnomeModule(ExtensionModule): scan_command += ['--no-libtool', '--namespace=' + ns, '--nsversion=' + nsversion, '--warn-all', '--output', '@OUTPUT@'] + header = kwargs.pop('header', None) + if header: + if not isinstance(header, str): + raise MesonException('header must be a string') + scan_command += ['--c-include=' + header] + extra_args = mesonlib.stringlistify(kwargs.pop('extra_args', [])) scan_command += extra_args scan_command += ['-I' + srcdir, diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py index a63aff8..4ab07b9 100644 --- a/mesonbuild/modules/qt4.py +++ b/mesonbuild/modules/qt4.py @@ -21,6 +21,7 @@ from . import ExtensionModule import xml.etree.ElementTree as ET from . import ModuleReturnValue from ..interpreterbase import permittedKwargs +from . import get_include_args class Qt4Module(ExtensionModule): tools_detected = False @@ -97,10 +98,10 @@ class Qt4Module(ExtensionModule): except Exception: return [] - @permittedKwargs({'moc_headers', 'moc_sources', 'ui_files', 'qresources', 'method'}) + @permittedKwargs({'moc_headers', 'moc_sources', 'include_directories', 'ui_files', 'qresources', 'method'}) def preprocess(self, state, args, kwargs): - rcc_files, ui_files, moc_headers, moc_sources, sources \ - = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'sources', pop = True) + rcc_files, ui_files, moc_headers, moc_sources, sources, include_directories \ + = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'sources', 'include_directories', pop = True) sources += args[1:] method = kwargs.get('method', 'auto') self._detect_tools(state.environment, method) @@ -133,9 +134,10 @@ class Qt4Module(ExtensionModule): ui_gen = build.Generator([self.uic], ui_kwargs) ui_output = ui_gen.process_files('Qt4 ui', ui_files, state) sources.append(ui_output) + inc = get_include_args(include_dirs=include_directories) if len(moc_headers) > 0: moc_kwargs = {'output': 'moc_@BASENAME@.cpp', - 'arguments': ['@INPUT@', '-o', '@OUTPUT@']} + 'arguments': inc + ['@INPUT@', '-o', '@OUTPUT@']} moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt4 moc header', moc_headers, state) sources.append(moc_output) diff --git a/mesonbuild/modules/qt5.py b/mesonbuild/modules/qt5.py index 08ce662..001caa7 100644 --- a/mesonbuild/modules/qt5.py +++ b/mesonbuild/modules/qt5.py @@ -21,6 +21,7 @@ from . import ExtensionModule import xml.etree.ElementTree as ET from . import ModuleReturnValue from ..interpreterbase import permittedKwargs +from . import get_include_args class Qt5Module(ExtensionModule): tools_detected = False @@ -103,10 +104,10 @@ class Qt5Module(ExtensionModule): except Exception: return [] - @permittedKwargs({'moc_headers', 'moc_sources', 'ui_files', 'qresources', 'method'}) + @permittedKwargs({'moc_headers', 'moc_sources', 'include_directories', 'ui_files', 'qresources', 'method'}) def preprocess(self, state, args, kwargs): - rcc_files, ui_files, moc_headers, moc_sources, sources \ - = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'sources', pop = True) + rcc_files, ui_files, moc_headers, moc_sources, sources, include_directories \ + = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'sources', 'include_directories', pop = True) sources += args[1:] method = kwargs.get('method', 'auto') self._detect_tools(state.environment, method) @@ -139,9 +140,10 @@ class Qt5Module(ExtensionModule): ui_gen = build.Generator([self.uic], ui_kwargs) ui_output = ui_gen.process_files('Qt5 ui', ui_files, state) sources.append(ui_output) + inc = get_include_args(include_dirs=include_directories) if len(moc_headers) > 0: moc_kwargs = {'output': 'moc_@BASENAME@.cpp', - 'arguments': ['@INPUT@', '-o', '@OUTPUT@']} + 'arguments': inc + ['@INPUT@', '-o', '@OUTPUT@']} moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt5 moc header', moc_headers, state) sources.append(moc_output) diff --git a/run_tests.py b/run_tests.py index f74ff13..00c97ca 100755 --- a/run_tests.py +++ b/run_tests.py @@ -90,7 +90,7 @@ def get_backend_commands(backend, debug=False): test_cmd = cmd + ['-target', 'RUN_TESTS'] elif backend is Backend.ninja: # We need at least 1.6 because of -w dupbuild=err - cmd = [detect_ninja('1.6'), '-w', 'dupbuild=err'] + cmd = [detect_ninja('1.6'), '-w', 'dupbuild=err', '-d', 'explain'] if cmd[0] is None: raise RuntimeError('Could not find Ninja v1.6 or newer') if debug: diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build index d9cab6f..c6f108b 100644 --- a/test cases/frameworks/4 qt/meson.build +++ b/test cases/frameworks/4 qt/meson.build @@ -70,5 +70,15 @@ foreach qt : ['qt4', 'qt5'] dependencies : qtcore) test(qt + 'maninclude', qtmaninclude) + + # building Qt plugins implies to give include path to moc + plugin_includes = include_directories('pluginInterface', 'plugin') + pluginpreprocess = qtmodule.preprocess( + moc_headers : 'plugin/plugin.h', + include_directories : plugin_includes + ) + plugin = library('plugin', 'plugin/plugin.cpp', pluginpreprocess, + include_directories : plugin_includes, + dependencies : qtcore) endif endforeach diff --git a/test cases/frameworks/4 qt/plugin/plugin.cpp b/test cases/frameworks/4 qt/plugin/plugin.cpp new file mode 100644 index 0000000..eeae98d --- /dev/null +++ b/test cases/frameworks/4 qt/plugin/plugin.cpp @@ -0,0 +1,7 @@ +#include "plugin.h" +#include <QFile> + +QString plugin1::getResource() +{ + return "hello world"; +} diff --git a/test cases/frameworks/4 qt/plugin/plugin.h b/test cases/frameworks/4 qt/plugin/plugin.h new file mode 100644 index 0000000..1138f41 --- /dev/null +++ b/test cases/frameworks/4 qt/plugin/plugin.h @@ -0,0 +1,11 @@ +#pragma once +#include <plugin_if.h> + +class plugin1:public QObject,public PluginInterface +{ + Q_OBJECT + Q_INTERFACES(PluginInterface) + Q_PLUGIN_METADATA(IID "demo.PluginInterface" FILE "plugin.json") +public: + QString getResource() override; +}; diff --git a/test cases/frameworks/4 qt/plugin/plugin.json b/test cases/frameworks/4 qt/plugin/plugin.json new file mode 100644 index 0000000..6c6a011 --- /dev/null +++ b/test cases/frameworks/4 qt/plugin/plugin.json @@ -0,0 +1,3 @@ +{ + "name" : "Plugin1" +} diff --git a/test cases/frameworks/4 qt/pluginInterface/plugin_if.h b/test cases/frameworks/4 qt/pluginInterface/plugin_if.h new file mode 100644 index 0000000..97d2800 --- /dev/null +++ b/test cases/frameworks/4 qt/pluginInterface/plugin_if.h @@ -0,0 +1,21 @@ +#ifndef PLUGIN_IF_H +#define PLUGIN_IF_H + +#include <QString> +#include <QtPlugin> + +/** + * @brief Interface for a plugin + */ +class PluginInterface +{ +public: + virtual ~PluginInterface() = default; + + /// Initializes the plugin + virtual QString getResource() = 0; +}; + +Q_DECLARE_INTERFACE(PluginInterface, "demo.PluginInterface") + +#endif diff --git a/test cases/frameworks/7 gnome/gir/dep1/meson.build b/test cases/frameworks/7 gnome/gir/dep1/meson.build index 75dd731..baa0b1d 100644 --- a/test cases/frameworks/7 gnome/gir/dep1/meson.build +++ b/test cases/frameworks/7 gnome/gir/dep1/meson.build @@ -19,6 +19,7 @@ dep1gir = gnome.generate_gir( namespace : 'MesonDep1', symbol_prefix : 'meson', identifier_prefix : 'Meson', + header: 'dep1.h', includes : ['GObject-2.0', 'MesonDep2-1.0'], dependencies : [dep2_dep], install : true |