Skip to content

Commit

Permalink
gnome: Add fatal_warnings kwarg to generate_gir()
Browse files Browse the repository at this point in the history
  • Loading branch information
xclaesse committed Jun 16, 2020
1 parent 0a61f51 commit 0b4cf5a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/markdown/Gnome-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ There are several keyword arguments. Many of these map directly to the
* `link_with`: list of libraries to link with
* `symbol_prefix`: the symbol prefix for the gir object, e.g. `gtk`,
(*Since 0.43.0*) an ordered list of multiple prefixes is allowed
* `fatal_warnings`: *Since 0.55.0* turn scanner warnings into fatal errors.

Returns an array of two elements which are: `[gir_target,
typelib_target]`
Expand Down
5 changes: 5 additions & 0 deletions docs/markdown/snippets/gir_fatal_warnings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Fatal warnings in `gnome.generate_gir()`

`gnome.generate_gir()` now has `fatal_warnings` keyword argument to abort when
a warning is produced. This is useful for example in CI environment where it's
important to catch potential issues.
13 changes: 11 additions & 2 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,12 @@ def _get_scanner_ldflags(ldflags):
if f.startswith(('-L', '-l', '--extra-library')):
yield f

@FeatureNewKwargs('build target', '0.40.0', ['build_by_default'])
@FeatureNewKwargs('generate_gir', '0.55.0', ['fatal_warnings'])
@FeatureNewKwargs('generate_gir', '0.40.0', ['build_by_default'])
@permittedKwargs({'sources', 'nsversion', 'namespace', 'symbol_prefix', 'identifier_prefix',
'export_packages', 'includes', 'dependencies', 'link_with', 'include_directories',
'install', 'install_dir_gir', 'install_dir_typelib', 'extra_args',
'packages', 'header', 'build_by_default'})
'packages', 'header', 'build_by_default', 'fatal_warnings'})
def generate_gir(self, state, args, kwargs):
if not args:
raise MesonException('generate_gir takes at least one argument')
Expand Down Expand Up @@ -798,6 +799,14 @@ def generate_gir(self, state, args, kwargs):
scan_command += ['--sources-top-dirs', os.path.join(state.environment.get_source_dir(), self.interpreter.subproject_dir, state.subproject)]
scan_command += ['--sources-top-dirs', os.path.join(state.environment.get_build_dir(), self.interpreter.subproject_dir, state.subproject)]

if '--warn-error' in scan_command:
mlog.deprecation('Passing --warn-error is deprecated in favor of "fatal_warnings" keyword argument')
fatal_warnings = kwargs.get('fatal_warnings', False)
if not isinstance(fatal_warnings, bool):
raise MesonException('fatal_warnings keyword argument must be string.')
if fatal_warnings:
scan_command.append('--warn-error')

scan_target = self._make_gir_target(state, girfile, scan_command, depends, kwargs)

typelib_output = '%s-%s.typelib' % (ns, nsversion)
Expand Down

0 comments on commit 0b4cf5a

Please sign in to comment.