aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2017-08-31 07:40:53 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2017-09-04 19:26:04 +0300
commit04b2c67b7d779e070731d440281640844892be66 (patch)
tree6874d97543f46b16a2b1794e53f380576f45b8be
parentc63aa0372b7acd8f6a094ca240eb39c8aab646cf (diff)
downloadmeson-04b2c67b7d779e070731d440281640844892be66.zip
meson-04b2c67b7d779e070731d440281640844892be66.tar.gz
meson-04b2c67b7d779e070731d440281640844892be66.tar.bz2
gnome.gdbus_codegen(): Add annotations keyword
Fixes #2123
-rw-r--r--docs/markdown/Gnome-module.md25
-rw-r--r--mesonbuild/modules/gnome.py14
-rw-r--r--test cases/frameworks/7 gnome/gdbus/meson.build6
3 files changed, 39 insertions, 6 deletions
diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md
index e81875a..3672761 100644
--- a/docs/markdown/Gnome-module.md
+++ b/docs/markdown/Gnome-module.md
@@ -220,14 +220,31 @@ useful when running the application locally for example during tests.
Compiles the given XML schema into gdbus source code. Takes two
positional arguments, the first one specifies the name of the source
-files and the second specifies the XML file name. There are three
-keyword arguments. `interface_prefix` and `namespace` map to
-corresponding features of the compiler while `object_manager` (since
-0.40.0), when set to true, generates object manager code.
+files and the second specifies the XML file name.
+
+* `interface_prefix`: prefix for the interface
+* `namespace`: namespace of the interface
+* `object_manager`: *(Added 0.40.0)* if true generates object manager code
+* `annotations`: *(Added 0.43.0)* list of lists of 3 strings for the annotation for `'ELEMENT', 'KEY', 'VALUE'`
Returns an opaque object containing the source files. Add it to a top
level target's source list.
+Example:
+
+```meson
+gnome = import('gnome')
+
+# The returned source would be passed to another target
+gdbus_src = gnome.gdbus_codegen('example-interface', 'com.example.Sample.xml',
+ interface_prefix : 'com.example.',
+ namespace : 'Sample',
+ annotations : [
+ ['com.example.Hello()', 'org.freedesktop.DBus.Deprecated', 'true']
+ ]
+)
+```
+
### gnome.generate_vapi()
Creates a VAPI file from gir. The first argument is the name of the
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 3f1b016..19a1198 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -850,7 +850,7 @@ class GnomeModule(ExtensionModule):
return []
- @permittedKwargs({'interface_prefix', 'namespace', 'object_manager', 'build_by_default'})
+ @permittedKwargs({'interface_prefix', 'namespace', 'object_manager', 'build_by_default', 'annotations'})
def gdbus_codegen(self, state, args, kwargs):
if len(args) != 2:
raise MesonException('Gdbus_codegen takes two arguments, name and xml file.')
@@ -865,6 +865,18 @@ class GnomeModule(ExtensionModule):
if kwargs.get('object_manager', False):
cmd += ['--c-generate-object-manager']
+ # Annotations are a bit ugly in that they are a list of lists of strings...
+ annotations = kwargs.pop('annotations', [])
+ if not isinstance(annotations, list):
+ raise MesonException('annotations takes a list')
+ if annotations and isinstance(annotations, list) and not isinstance(annotations[0], list):
+ annotations = [annotations]
+
+ for annotation in annotations:
+ if len(annotation) != 3 or not all(isinstance(i, str) for i in annotation):
+ raise MesonException('Annotations must be made up of 3 strings for ELEMENT, KEY, and VALUE')
+ cmd += ['--annotate'] + annotation
+
# https://git.gnome.org/browse/glib/commit/?id=ee09bb704fe9ccb24d92dd86696a0e6bb8f0dc1a
if mesonlib.version_compare(self._get_native_glib_version(state), '>= 2.51.3'):
cmd += ['--output-directory', '@OUTDIR@', '--generate-c-code', namebase, '@INPUT@']
diff --git a/test cases/frameworks/7 gnome/gdbus/meson.build b/test cases/frameworks/7 gnome/gdbus/meson.build
index 7f7c97b..f8a8eba 100644
--- a/test cases/frameworks/7 gnome/gdbus/meson.build
+++ b/test cases/frameworks/7 gnome/gdbus/meson.build
@@ -1,6 +1,10 @@
gdbus_src = gnome.gdbus_codegen('generated-gdbus', 'com.example.Sample.xml',
interface_prefix : 'com.example.',
- namespace : 'Sample')
+ namespace : 'Sample',
+ annotations : [
+ ['com.example.Hello()', 'org.freedesktop.DBus.Deprecated', 'true']
+ ]
+)
gdbus_exe = executable('gdbus-test', 'gdbusprog.c',
gdbus_src,