aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Gnome-module.md16
-rw-r--r--mesonbuild/modules/gnome.py86
-rw-r--r--test cases/frameworks/7 gnome/gdbus/meson.build10
3 files changed, 93 insertions, 19 deletions
diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md
index ad3715e..3db6cc0 100644
--- a/docs/markdown/Gnome-module.md
+++ b/docs/markdown/Gnome-module.md
@@ -235,9 +235,21 @@ files and the second specifies the XML file name.
* `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'`
* `docbook`: *(Added 0.43.0)* prefix to generate `'PREFIX'-NAME.xml` docbooks
+* `build_by_default`: causes, when set to true, to have this target be
+ built by default, that is, when invoking plain `ninja`, the default
+ value is true for all built target types
+* `install_dir`: (*Added 0.46.0*) location to install the header or
+ bundle depending on previous options
+* `install_header`: (*Added 0.46.0*) if true, install the header file
+
+Starting *0.46.0*, this function returns a list of at least two custom targets
+(in order): one for the source code and one for the header. The list will
+contain a third custom target for the generated docbook files if that keyword
+argument is passed.
-Returns an opaque object containing the source files. Add it to a top
-level target's source list.
+Earlier versions return a single custom target representing all the outputs.
+Generally, you should just add this list of targets to a top level target's
+source list.
Example:
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 9c73667..4dc29c3 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -869,7 +869,7 @@ This will become a hard error in the future.''')
return []
@permittedKwargs({'interface_prefix', 'namespace', 'object_manager', 'build_by_default',
- 'annotations', 'docbook'})
+ 'annotations', 'docbook', 'install', 'install_header'})
def gdbus_codegen(self, state, args, kwargs):
if len(args) != 2:
raise MesonException('Gdbus_codegen takes two arguments, name and xml file.')
@@ -883,8 +883,7 @@ This will become a hard error in the future.''')
cmd += ['--c-namespace', kwargs.pop('namespace')]
if kwargs.get('object_manager', False):
cmd += ['--c-generate-object-manager']
- if 'docbook' in kwargs:
- cmd += ['--generate-docbook', kwargs.pop('docbook')]
+ build_by_default = kwargs.get('build_by_default', False)
# Annotations are a bit ugly in that they are a list of lists of strings...
annotations = kwargs.pop('annotations', [])
@@ -898,21 +897,74 @@ This will become a hard error in the future.''')
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@']
+ # https://git.gnome.org/browse/glib/commit/?id=e4d68c7b3e8b01ab1a4231bf6da21d045cb5a816
+ if mesonlib.version_compare(self._get_native_glib_version(state), '>= 2.55.2'):
+ targets = []
+ install_header = kwargs.get('install_header', False)
+ install_dir = kwargs.get('install_dir', state.environment.coredata.get_builtin_option('includedir'))
+
+ output = namebase + '.c'
+ custom_kwargs = {'input': xml_file,
+ 'output': output,
+ 'command': cmd + ['--body', '--output', '@OUTDIR@/' + output, '@INPUT@'],
+ 'build_by_default': build_by_default
+ }
+ targets.append(build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs))
+
+ output = namebase + '.h'
+ custom_kwargs = {'input': xml_file,
+ 'output': output,
+ 'command': cmd + ['--header', '--output', '@OUTDIR@/' + output, '@INPUT@'],
+ 'build_by_default': build_by_default,
+ 'install': install_header,
+ 'install_dir': install_dir
+ }
+ targets.append(build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs))
+
+ if 'docbook' in kwargs:
+ docbook = kwargs['docbook']
+ if not isinstance(docbook, str):
+ raise MesonException('docbook value must be a string.')
+
+ docbook_cmd = cmd + ['--output-directory', '@OUTDIR@', '--generate-docbook', docbook, '@INPUT@']
+
+ output = namebase + '-docbook'
+ custom_kwargs = {'input': xml_file,
+ 'output': output,
+ 'command': docbook_cmd,
+ 'build_by_default': build_by_default
+ }
+ targets.append(build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs))
+
+ objects = targets
else:
- self._print_gdbus_warning()
- cmd += ['--generate-c-code', '@OUTDIR@/' + namebase, '@INPUT@']
- outputs = [namebase + '.c', namebase + '.h']
- custom_kwargs = {'input': xml_file,
- 'output': outputs,
- 'command': cmd
- }
- if 'build_by_default' in kwargs:
- custom_kwargs['build_by_default'] = kwargs['build_by_default']
- ct = build.CustomTarget(target_name, state.subdir, state.subproject, custom_kwargs)
- return ModuleReturnValue(ct, [ct])
+ if 'docbook' in kwargs:
+ docbook = kwargs['docbook']
+ if not isinstance(docbook, str):
+ raise MesonException('docbook value must be a string.')
+
+ cmd += ['--generate-docbook', docbook]
+
+ # 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@']
+ else:
+ self._print_gdbus_warning()
+ cmd += ['--generate-c-code', '@OUTDIR@/' + namebase, '@INPUT@']
+ outputs = [namebase + '.c', namebase + '.h']
+ custom_kwargs = {'input': xml_file,
+ 'output': outputs,
+ 'command': cmd,
+ 'build_by_default': build_by_default
+ }
+ ct = build.CustomTarget(target_name, state.subdir, state.subproject, custom_kwargs)
+ # Ensure that the same number (and order) of arguments are returned
+ # regardless of the gdbus-codegen (glib) version being used
+ targets = [ct, ct]
+ if 'docbook' in kwargs:
+ targets.append(ct)
+ objects = [ct]
+ return ModuleReturnValue(targets, objects)
@permittedKwargs({'sources', 'c_template', 'h_template', 'install_header', 'install_dir',
'comments', 'identifier_prefix', 'symbol_prefix', 'eprod', 'vprod',
diff --git a/test cases/frameworks/7 gnome/gdbus/meson.build b/test cases/frameworks/7 gnome/gdbus/meson.build
index ea91caa..57d7f23 100644
--- a/test cases/frameworks/7 gnome/gdbus/meson.build
+++ b/test cases/frameworks/7 gnome/gdbus/meson.build
@@ -1,3 +1,12 @@
+gdbus_src = gnome.gdbus_codegen('generated-gdbus-no-docbook', 'com.example.Sample.xml',
+ interface_prefix : 'com.example.',
+ namespace : 'Sample',
+ annotations : [
+ ['com.example.Hello()', 'org.freedesktop.DBus.Deprecated', 'true']
+ ],
+)
+assert(gdbus_src.length() == 2, 'expected 2 targets')
+
gdbus_src = gnome.gdbus_codegen('generated-gdbus', 'com.example.Sample.xml',
interface_prefix : 'com.example.',
namespace : 'Sample',
@@ -6,6 +15,7 @@ gdbus_src = gnome.gdbus_codegen('generated-gdbus', 'com.example.Sample.xml',
],
docbook : 'generated-gdbus-doc'
)
+assert(gdbus_src.length() == 3, 'expected 3 targets')
gdbus_exe = executable('gdbus-test', 'gdbusprog.c',
gdbus_src,