allow dependency checks to bubble up feature warnings to the interpreter

It would be too difficult and probably a layering violation to give an
interpreter handle to the inner guts of every dependency. What we can do
instead is let every dependency track:

- the Feature checks it can produce,
- the version attribute for when it was implemented

while leaving the interpreter in charge of actually emitting them.
pull/10044/head
Eli Schwartz 3 years ago committed by Dylan Baker
parent d39b330075
commit 23e767176e
  1. 3
      mesonbuild/dependencies/base.py
  2. 5
      mesonbuild/interpreter/interpreter.py

@ -30,6 +30,7 @@ if T.TYPE_CHECKING:
from .._typing import ImmutableListProtocol from .._typing import ImmutableListProtocol
from ..compilers.compilers import Compiler from ..compilers.compilers import Compiler
from ..environment import Environment from ..environment import Environment
from ..interpreterbase import FeatureCheckBase
from ..build import BuildTarget, CustomTarget, IncludeDirs from ..build import BuildTarget, CustomTarget, IncludeDirs
from ..mesonlib import FileOrString from ..mesonlib import FileOrString
@ -92,6 +93,8 @@ class Dependency(HoldableObject):
self.sources: T.List[T.Union['FileOrString', 'CustomTarget']] = [] self.sources: T.List[T.Union['FileOrString', 'CustomTarget']] = []
self.include_type = self._process_include_type_kw(kwargs) self.include_type = self._process_include_type_kw(kwargs)
self.ext_deps: T.List[Dependency] = [] self.ext_deps: T.List[Dependency] = []
self.featurechecks: T.List['FeatureCheckBase'] = []
self.feature_since: T.Optional[T.Tuple[str, str]] = None
def __repr__(self) -> str: def __repr__(self) -> str:
return f'<{self.__class__.__name__} {self.name}: {self.is_found}>' return f'<{self.__class__.__name__} {self.name}: {self.is_found}>'

@ -1601,6 +1601,11 @@ external dependencies (including libraries) must go to "dependencies".''')
if wanted != actual: if wanted != actual:
mlog.debug(f'Current include type of {args[0]} is {actual}. Converting to requested {wanted}') mlog.debug(f'Current include type of {args[0]} is {actual}. Converting to requested {wanted}')
d = d.generate_system_dependency(wanted) d = d.generate_system_dependency(wanted)
if d.feature_since is not None:
version, extra_msg = d.feature_since
FeatureNew.single_use(f'dep {d.name!r} custom lookup', version, self.subproject, extra_msg, node)
for f in d.featurechecks:
f.use(self.subproject, node)
return d return d
@FeatureNew('disabler', '0.44.0') @FeatureNew('disabler', '0.44.0')

Loading…
Cancel
Save