From d7b401f7d7aec217ee6c18dd44e0978beaf6bd5f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 11 Apr 2018 21:30:47 +0530 Subject: [PATCH] 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 --- docs/markdown/Gnome-module.md | 13 ++++++++----- mesonbuild/modules/gnome.py | 19 +++++++++++-------- .../frameworks/7 gnome/gdbus/meson.build | 10 ++++++++++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md index 6de21ffac..3db6cc035 100644 --- a/docs/markdown/Gnome-module.md +++ b/docs/markdown/Gnome-module.md @@ -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: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 72cdc39c3..b4af8d850 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -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', diff --git a/test cases/frameworks/7 gnome/gdbus/meson.build b/test cases/frameworks/7 gnome/gdbus/meson.build index ea91caa6e..57d7f236a 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,