From 351b59f03adcdbf5a4efbaba2446c0e40a456ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Tue, 16 Jan 2018 10:41:47 +0100 Subject: gnome: Split header and code targets in gdbus_codegen() The development version of `glib` (2.55.2) has acquired support for generating gdbus header and source code files separately. This allows dependencies to be more fine grained on those targets depending only on the header. --- mesonbuild/modules/gnome.py | 71 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 17 deletions(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 9c73667..3e34e34 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,59 @@ 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_cmd = cmd + ['--output-directory', '@OUTDIR@', '--generate-docbook', kwargs.pop('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)) 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: + cmd += ['--generate-docbook', kwargs.pop('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) + targets = [ct, ct, ct] + return ModuleReturnValue(targets, targets) @permittedKwargs({'sources', 'c_template', 'h_template', 'install_header', 'install_dir', 'comments', 'identifier_prefix', 'symbol_prefix', 'eprod', 'vprod', -- cgit v1.1 From b2636ceef9cf838b4368583c41f5583338266eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Wed, 11 Apr 2018 16:51:23 +0200 Subject: gnome: Validate docbook parameter is a string The `docbook` parameter used in `gdbus_codegen` should contain the prefix string in `PREFIX-NAME.xml`. Therefore it has to be validated as a string. --- mesonbuild/modules/gnome.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 3e34e34..72cdc39 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -922,7 +922,11 @@ 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_cmd = cmd + ['--output-directory', '@OUTDIR@', '--generate-docbook', kwargs.pop('docbook'), '@INPUT@'] + docbook = kwargs.pop('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, @@ -933,7 +937,11 @@ 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: - cmd += ['--generate-docbook', kwargs.pop('docbook')] + docbook = kwargs.pop('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'): -- cgit v1.1 From d7b401f7d7aec217ee6c18dd44e0978beaf6bd5f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 11 Apr 2018 21:30:47 +0530 Subject: 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 --- mesonbuild/modules/gnome.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 72cdc39..b4af8d8 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', -- cgit v1.1 From e656b9c819b073a9af501619cf512f63aa16e8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Thu, 12 Apr 2018 08:08:39 +0200 Subject: gdbus_codegen: Fix custom target name The namebase which is used as the target name, also holds part of the file names. This used in combination generates files with wrong names. --- mesonbuild/modules/gnome.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index b4af8d8..43a9d1c 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -873,9 +873,10 @@ 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] + '-gdbus' + namebase = args[0] xml_file = args[1] - cmd = [find_program('gdbus-codegen', namebase)] + target_name = namebase + '-gdbus' + cmd = [find_program('gdbus-codegen', target_name)] if 'interface_prefix' in kwargs: cmd += ['--interface-prefix', kwargs.pop('interface_prefix')] if 'namespace' in kwargs: @@ -954,7 +955,7 @@ This will become a hard error in the future.''') 'command': cmd, 'build_by_default': build_by_default } - ct = build.CustomTarget(namebase, state.subdir, state.subproject, custom_kwargs) + 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] -- cgit v1.1 From 435cd8c922d45bb95fa5f2fd519b77d24ba8e321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Thu, 12 Apr 2018 08:18:07 +0200 Subject: gdbus_codegen: Fix new generated objects The `ct` variable used in the ModuleReturnValue is created only for versions earlier than 2.55.2. However, in newer versions that variable does not exist. --- mesonbuild/modules/gnome.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 43a9d1c..4dc29c3 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -935,6 +935,8 @@ This will become a hard error in the future.''') 'build_by_default': build_by_default } targets.append(build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs)) + + objects = targets else: if 'docbook' in kwargs: docbook = kwargs['docbook'] @@ -961,7 +963,8 @@ This will become a hard error in the future.''') targets = [ct, ct] if 'docbook' in kwargs: targets.append(ct) - return ModuleReturnValue(targets, [ct]) + objects = [ct] + return ModuleReturnValue(targets, objects) @permittedKwargs({'sources', 'c_template', 'h_template', 'install_header', 'install_dir', 'comments', 'identifier_prefix', 'symbol_prefix', 'eprod', 'vprod', -- cgit v1.1