gnome: Support new glib-genmarshal arguments

The glib-genmarshal tool was rewritten in GLib 2.53.3, and now supports
more command line arguments, such as:

  "--pragma-once": emits a "#pragma once" instead of the old header
    guards when generating the header file
  "--prototypes": emits the marshallers prototype when generating the
    source file
  "-D,-U": defines and undefines pre-processor symbols
  "--include-header": emits an "#include" directive when generating the
    source file for the specified header file

Meson should take advantage of these new options, as they can be used to
replace most of the ad hoc build rules that projects are currently using
to implement the same thing.

Instead of mapping each option to a named argument, I used the same
approach as the compile_resources() and generate_gir() methods; the
genmarshal() method now has an 'extra_args' argument that can be used to
pass extra arguments to the glib-genmarshal tool.
pull/2049/head
Emmanuele Bassi 8 years ago
parent 99fdb6c19e
commit de45352d9d
  1. 16
      mesonbuild/modules/gnome.py

@ -954,7 +954,8 @@ class GnomeModule(ExtensionModule):
absolute_paths=True) absolute_paths=True)
@permittedKwargs({'sources', 'prefix', 'install_header', 'install_dir', 'stdinc', @permittedKwargs({'sources', 'prefix', 'install_header', 'install_dir', 'stdinc',
'nostdinc', 'internal', 'skip_source', 'valist_marshallers'}) 'nostdinc', 'internal', 'skip_source', 'valist_marshallers',
'extra_args'})
def genmarshal(self, state, args, kwargs): def genmarshal(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException( raise MesonException(
@ -970,15 +971,24 @@ class GnomeModule(ExtensionModule):
raise MesonException( raise MesonException(
'Sources keyword argument must be a string or array.') 'Sources keyword argument must be a string or array.')
new_genmarshal = mesonlib.version_compare(self._get_native_glib_version(state), '>= 2.53.3')
cmd = [find_program('glib-genmarshal', output + '_genmarshal')] cmd = [find_program('glib-genmarshal', output + '_genmarshal')]
known_kwargs = ['internal', 'nostdinc', 'skip_source', 'stdinc', known_kwargs = ['internal', 'nostdinc', 'skip_source', 'stdinc',
'valist_marshallers'] 'valist_marshallers', 'extra_args']
known_custom_target_kwargs = ['build_always', 'depends', known_custom_target_kwargs = ['build_always', 'depends',
'depend_files', 'install_dir', 'depend_files', 'install_dir',
'install_header'] 'install_header']
for arg, value in kwargs.items(): for arg, value in kwargs.items():
if arg == 'prefix': if arg == 'prefix':
cmd += ['--prefix', value] cmd += ['--prefix', value]
elif arg == 'extra_args':
if new_genmarshal:
cmd += mesonlib.stringlistify(value, [])
else:
mlog.warning('The current version of GLib does not support extra arguments \n'
'for glib-genmarshal. You need at least GLib 2.53.3. See ',
mlog.bold('https://github.com/mesonbuild/meson/pull/2049'))
elif arg in known_kwargs and value: elif arg in known_kwargs and value:
cmd += ['--' + arg.replace('_', '-')] cmd += ['--' + arg.replace('_', '-')]
elif arg not in known_custom_target_kwargs: elif arg not in known_custom_target_kwargs:
@ -1014,6 +1024,8 @@ class GnomeModule(ExtensionModule):
custom_kwargs['install'] = install_header custom_kwargs['install'] = install_header
if install_dir is not None: if install_dir is not None:
custom_kwargs['install_dir'] = install_dir custom_kwargs['install_dir'] = install_dir
if new_genmarshal:
cmd += ['--pragma-once']
custom_kwargs['command'] = cmd + ['--header', '@INPUT@'] custom_kwargs['command'] = cmd + ['--header', '@INPUT@']
custom_kwargs['output'] = header_file custom_kwargs['output'] = header_file
header = build.CustomTarget(output + '_h', state.subdir, custom_kwargs) header = build.CustomTarget(output + '_h', state.subdir, custom_kwargs)

Loading…
Cancel
Save