gdbus_codegen: Return 2 targets when docbook is disabled

Also document this behaviour, test it, and fix the return value from
the module -- we create one target and return it thrice to the build
file
pull/2930/head
Nirbheek Chauhan 7 years ago
parent b2636ceef9
commit d7b401f7d7
  1. 13
      docs/markdown/Gnome-module.md
  2. 19
      mesonbuild/modules/gnome.py
  3. 10
      test cases/frameworks/7 gnome/gdbus/meson.build

@ -242,11 +242,14 @@ files and the second specifies the XML file name.
bundle depending on previous options
* `install_header`: (*Added 0.46.0*) if true, install the header file
If gdbus-codegen version is greater than 2.55.2 it will return at
most three targets, one for the souce code, one for the header and
another one for the files generated with docbook. Otherwise, it
returns an opaque object containing the source files. Add it to a
top level target's source list.
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.
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:

@ -873,10 +873,9 @@ This will become a hard error in the future.''')
def gdbus_codegen(self, state, args, kwargs):
if len(args) != 2:
raise MesonException('Gdbus_codegen takes two arguments, name and xml file.')
namebase = args[0]
namebase = args[0] + '-gdbus'
xml_file = args[1]
target_name = namebase + '-gdbus'
cmd = [find_program('gdbus-codegen', target_name)]
cmd = [find_program('gdbus-codegen', namebase)]
if 'interface_prefix' in kwargs:
cmd += ['--interface-prefix', kwargs.pop('interface_prefix')]
if 'namespace' in kwargs:
@ -922,7 +921,7 @@ This will become a hard error in the future.''')
targets.append(build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs))
if 'docbook' in kwargs:
docbook = kwargs.pop('docbook')
docbook = kwargs['docbook']
if not isinstance(docbook, str):
raise MesonException('docbook value must be a string.')
@ -937,7 +936,7 @@ This will become a hard error in the future.''')
targets.append(build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs))
else:
if 'docbook' in kwargs:
docbook = kwargs.pop('docbook')
docbook = kwargs['docbook']
if not isinstance(docbook, str):
raise MesonException('docbook value must be a string.')
@ -955,9 +954,13 @@ This will become a hard error in the future.''')
'command': cmd,
'build_by_default': build_by_default
}
ct = build.CustomTarget(target_name, state.subdir, state.subproject, custom_kwargs)
targets = [ct, ct, ct]
return ModuleReturnValue(targets, targets)
ct = build.CustomTarget(namebase, 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)
return ModuleReturnValue(targets, [ct])
@permittedKwargs({'sources', 'c_template', 'h_template', 'install_header', 'install_dir',
'comments', 'identifier_prefix', 'symbol_prefix', 'eprod', 'vprod',

@ -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,

Loading…
Cancel
Save