pkgconfig: Only warn about deprecation at a location once

See: https://github.com/mesonbuild/meson/pull/4630#issuecomment-459235498
pull/4846/head
Nirbheek Chauhan 6 years ago committed by Xavier Claessens
parent 4bfe0a2568
commit 8481971ff2
  1. 32
      mesonbuild/modules/pkgconfig.py

@ -23,6 +23,8 @@ from . import ModuleReturnValue
from . import ExtensionModule from . import ExtensionModule
from ..interpreterbase import permittedKwargs, FeatureNew, FeatureNewKwargs from ..interpreterbase import permittedKwargs, FeatureNew, FeatureNewKwargs
already_warned_objs = set()
class DependenciesHelper: class DependenciesHelper:
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
@ -51,16 +53,21 @@ class DependenciesHelper:
self.priv_reqs += self._process_reqs(reqs) self.priv_reqs += self._process_reqs(reqs)
def _check_generated_pc_deprecation(self, obj): def _check_generated_pc_deprecation(self, obj):
if hasattr(obj, 'generated_pc_warn'): if not hasattr(obj, 'generated_pc_warn'):
mlog.deprecation('Library', mlog.bold(obj.name), 'was passed to the ' return
'"libraries" keyword argument of a previous call ' name = obj.generated_pc_warn[0]
'to generate() method instead of first positional ' if (name, obj.name) in already_warned_objs:
'argument.', 'Adding', mlog.bold(obj.generated_pc), return
'to "Requires" field, but this is a deprecated ' mlog.deprecation('Library', mlog.bold(obj.name), 'was passed to the '
'behaviour that will change in a future version ' '"libraries" keyword argument of a previous call '
'of Meson. Please report the issue if this ' 'to generate() method instead of first positional '
'warning cannot be avoided in your case.', 'argument.', 'Adding', mlog.bold(obj.generated_pc),
location=obj.generated_pc_warn) 'to "Requires" field, but this is a deprecated '
'behaviour that will change in a future version '
'of Meson. Please report the issue if this '
'warning cannot be avoided in your case.',
location=obj.generated_pc_warn[1])
already_warned_objs.add((name, obj.name))
def _process_reqs(self, reqs): def _process_reqs(self, reqs):
'''Returns string names of requirements''' '''Returns string names of requirements'''
@ -442,8 +449,9 @@ class PkgConfigModule(ExtensionModule):
for lib in deps.pub_libs: for lib in deps.pub_libs:
if not isinstance(lib, str) and not hasattr(lib, 'generated_pc'): if not isinstance(lib, str) and not hasattr(lib, 'generated_pc'):
lib.generated_pc = filebase lib.generated_pc = filebase
lib.generated_pc_warn = types.SimpleNamespace(subdir=state.subdir, location = types.SimpleNamespace(subdir=state.subdir,
lineno=state.current_lineno) lineno=state.current_lineno)
lib.generated_pc_warn = [name, location]
return ModuleReturnValue(res, [res]) return ModuleReturnValue(res, [res])
def initialize(*args, **kwargs): def initialize(*args, **kwargs):

Loading…
Cancel
Save