diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-10-29 22:40:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-29 22:40:28 +0200 |
commit | 68af8449d8576e27fb0390340f149f3001e8ea5f (patch) | |
tree | 921200359a63f5144cfea27ea2aef97e38c91ed1 | |
parent | 1b0048a7022a89f461cf4d01e7cdbf995bab70f5 (diff) | |
parent | cf759e529c9753b30bd926a75f629d3562fca990 (diff) | |
download | meson-68af8449d8576e27fb0390340f149f3001e8ea5f.zip meson-68af8449d8576e27fb0390340f149f3001e8ea5f.tar.gz meson-68af8449d8576e27fb0390340f149f3001e8ea5f.tar.bz2 |
Merge pull request #2529 from leiflm/qt5-add-moc-extra-arguments-keyword
Qt5-Module: Add `moc_extra_arguments` keyword support.
-rw-r--r-- | docs/markdown/Qt5-module.md | 17 | ||||
-rw-r--r-- | docs/markdown/snippets/qt5-moc_extra_arguments.md | 8 | ||||
-rw-r--r-- | mesonbuild/modules/qt.py | 12 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/manualinclude.cpp | 7 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/manualinclude.h | 6 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/meson.build | 1 |
6 files changed, 40 insertions, 11 deletions
diff --git a/docs/markdown/Qt5-module.md b/docs/markdown/Qt5-module.md index a8ad73d..aea2ae1 100644 --- a/docs/markdown/Qt5-module.md +++ b/docs/markdown/Qt5-module.md @@ -5,17 +5,22 @@ tools and steps required for Qt. The module has one method. ## preprocess -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` 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: +This method takes the following keyword arguments: + - `moc_headers`, `moc_sources`, `ui_files`, `qresources`, which define the files that require preprocessing with `moc`, `uic` and `rcc` + - `include_directories`, the directories to add to header search path for `moc` (optional) + - `moc_extra_arguments`, any additional arguments to `moc` (optional). Available since v0.44.0. + +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']) inc = include_directories('includes') -moc_files = qt5.preprocess(moc_headers : 'myclass.h', include_directories: inc) +moc_files = qt5.preprocess(moc_headers : 'myclass.h', + moc_extra_arguments: ['-DMAKES_MY_MOC_HEADER_COMPILE'], + include_directories: inc) executable('myprog', 'main.cpp', 'myclass.cpp', moc_files, include_directories: inc, dependencies : qt5_dep) diff --git a/docs/markdown/snippets/qt5-moc_extra_arguments.md b/docs/markdown/snippets/qt5-moc_extra_arguments.md new file mode 100644 index 0000000..957c3c7 --- /dev/null +++ b/docs/markdown/snippets/qt5-moc_extra_arguments.md @@ -0,0 +1,8 @@ +# Adds support for additional Qt5-Module keyword `moc_extra_arguments` + +When `moc`-ing sources, the `moc` tool does not know about any +preprocessor macros. The generated code might not match the input +files when the linking with the moc input sources happens. + +This amendment allows to specify a a list of additional arguments +passed to the `moc` tool. They are called `moc_extra_arguments`.
\ No newline at end of file diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 2f24740..0b7354f 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -84,10 +84,10 @@ class QtBaseModule: except Exception: return [] - @permittedKwargs({'moc_headers', 'moc_sources', 'include_directories', 'ui_files', 'qresources', 'method'}) + @permittedKwargs({'moc_headers', 'moc_sources', 'moc_extra_arguments', 'include_directories', 'ui_files', 'qresources', 'method'}) def preprocess(self, state, args, kwargs): - 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) + 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) sources += args[1:] method = kwargs.get('method', 'auto') self._detect_tools(state.environment, method) @@ -122,14 +122,16 @@ class QtBaseModule: sources.append(ui_output) inc = get_include_args(include_dirs=include_directories) if len(moc_headers) > 0: + arguments = moc_extra_arguments + inc + ['@INPUT@', '-o', '@OUTPUT@'] moc_kwargs = {'output': 'moc_@BASENAME@.cpp', - 'arguments': inc + ['@INPUT@', '-o', '@OUTPUT@']} + '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 + ['@INPUT@', '-o', '@OUTPUT@'] moc_kwargs = {'output': '@BASENAME@.moc', - 'arguments': ['@INPUT@', '-o', '@OUTPUT@']} + 'arguments': arguments} moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt{} moc source'.format(self.qt_version), moc_sources, state) sources.append(moc_output) diff --git a/test cases/frameworks/4 qt/manualinclude.cpp b/test cases/frameworks/4 qt/manualinclude.cpp index 0602882..6c1ac2f 100644 --- a/test cases/frameworks/4 qt/manualinclude.cpp +++ b/test cases/frameworks/4 qt/manualinclude.cpp @@ -6,6 +6,10 @@ ManualInclude::ManualInclude() { } +void ManualInclude::myslot(void) { + ; +} + class MocClass : public QObject { Q_OBJECT }; @@ -13,6 +17,9 @@ class MocClass : public QObject { int main(int argc, char **argv) { ManualInclude mi; MocClass mc; + QObject::connect(&mi, SIGNAL(mysignal(void)), + &mi, SLOT(myslot(void))); + emit mi.mysignal(); return 0; } diff --git a/test cases/frameworks/4 qt/manualinclude.h b/test cases/frameworks/4 qt/manualinclude.h index 4a00b6c..44bb7a7 100644 --- a/test cases/frameworks/4 qt/manualinclude.h +++ b/test cases/frameworks/4 qt/manualinclude.h @@ -8,8 +8,14 @@ class ManualInclude : public QObject { public: ManualInclude(); +#if defined(MOC_EXTRA_FLAG) +public slots: +#endif + void myslot(void); +#if defined(MOC_EXTRA_FLAG) signals: +#endif int mysignal(); }; diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build index 39be19f..b817228 100644 --- a/test cases/frameworks/4 qt/meson.build +++ b/test cases/frameworks/4 qt/meson.build @@ -61,6 +61,7 @@ foreach qt : ['qt4', 'qt5'] # headers but the user must manually include moc # files from sources. manpreprocessed = qtmodule.preprocess( + moc_extra_arguments : ['-DMOC_EXTRA_FLAG'], # This is just a random macro to test `moc_extra_arguments` moc_sources : 'manualinclude.cpp', moc_headers : 'manualinclude.h', method : get_option('method')) |