diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-10-14 23:53:34 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-10-15 14:38:44 -0400 |
commit | f52a5a7cd3f30645c1b746488ec921451545d9b6 (patch) | |
tree | f834e5af33c8968146d461a1bfa6cecdef634f01 | |
parent | a3f3ddf581b7dd07d8e48ac0ad32d0234ae9dd9e (diff) | |
download | meson-f52a5a7cd3f30645c1b746488ec921451545d9b6.zip meson-f52a5a7cd3f30645c1b746488ec921451545d9b6.tar.gz meson-f52a5a7cd3f30645c1b746488ec921451545d9b6.tar.bz2 |
wrap: move FeatureNew checks to a more natural place
Now, warnings are unconditionally raised when parsing the wrap file,
whether they are used or not. That being said, these warnings literally
just check for a couple of keys used in the .wrap ini file.
Moving these checks from the time of use to the time of loading, means
that we no longer report warnings only when originally downloading or
extracting the file or VCS repo.
It also means we no longer report warnings in one subproject, when a
wrap file is picked up from a different subproject because the first
subproject actually does a dependency lookup. This caused issues for the
WrapDB tooling, which uses patch_directory everywhere and the
superproject requires a suitable minimum version of meson for this...
but individual wraps might use a much lower version, and would then
raise a warning (in strict mode, converted to an error) when it resolved
a dependency from another WrapDB project.
Fixes #9118
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 4 | ||||
-rw-r--r-- | mesonbuild/wrap/wrap.py | 28 |
2 files changed, 18 insertions, 14 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index ba6bf11..bbe89fa 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -799,7 +799,7 @@ external dependencies (including libraries) must go to "dependencies".''') r = self.environment.wrap_resolver try: - subdir = r.resolve(subp_name, method, self.subproject) + subdir = r.resolve(subp_name, method) except wrap.WrapException as e: if not required: mlog.log(e) @@ -1107,7 +1107,7 @@ external dependencies (including libraries) must go to "dependencies".''') wrap_mode = self.coredata.get_option(OptionKey('wrap_mode')) if not self.is_subproject() or wrap_mode != WrapMode.nopromote: subdir = os.path.join(self.subdir, spdirname) - r = wrap.Resolver(self.environment.get_source_dir(), subdir, wrap_mode) + r = wrap.Resolver(self.environment.get_source_dir(), subdir, self.subproject, wrap_mode) if self.is_subproject(): self.environment.wrap_resolver.merge_wraps(r) else: diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index f941198..c8707b5 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -32,6 +32,7 @@ from pathlib import Path from . import WrapMode from .. import coredata from ..mesonlib import quiet_git, GIT, ProgressBar, MesonException +from ..interpreterbase import FeatureNew from .. import mesonlib if T.TYPE_CHECKING: @@ -90,8 +91,9 @@ class WrapNotFoundException(WrapException): pass class PackageDefinition: - def __init__(self, fname: str): + def __init__(self, fname: str, subproject: str = ''): self.filename = fname + self.subproject = subproject self.type = None # type: T.Optional[str] self.values = {} # type: T.Dict[str, str] self.provided_deps = {} # type: T.Dict[str, T.Optional[str]] @@ -141,8 +143,14 @@ class PackageDefinition: self.filename = str(fname) self.parse_wrap() self.redirected = True - return - self.parse_provide_section(config) + else: + self.parse_provide_section(config) + if 'patch_directory' in self.values: + FeatureNew('Wrap files with patch_directory', '0.55.0').use(self.subproject) + for what in ['patch', 'source']: + if f'{what}_filename' in self.values and f'{what}_url' not in self.values: + FeatureNew(f'Local wrap patch files without {what}_url', '0.55.0').use(self.subproject) + def parse_wrap_section(self, config: configparser.ConfigParser) -> None: if len(config.sections()) < 1: @@ -197,9 +205,10 @@ def verbose_git(cmd: T.List[str], workingdir: str, check: bool = False) -> bool: raise WrapException(str(e)) class Resolver: - def __init__(self, source_dir: str, subdir: str, wrap_mode: WrapMode = WrapMode.default) -> None: + def __init__(self, source_dir: str, subdir: str, subproject: str = '', wrap_mode: WrapMode = WrapMode.default) -> None: self.source_dir = source_dir self.subdir = subdir + self.subproject = subproject self.wrap_mode = wrap_mode self.subdir_root = os.path.join(source_dir, subdir) self.cachedir = os.path.join(self.subdir_root, 'packagecache') @@ -216,7 +225,7 @@ class Resolver: if not i.endswith('.wrap'): continue fname = os.path.join(self.subdir_root, i) - wrap = PackageDefinition(fname) + wrap = PackageDefinition(fname, self.subproject) self.wraps[wrap.name] = wrap if wrap.directory in dirs: dirs.remove(wrap.directory) @@ -225,7 +234,7 @@ class Resolver: if i in ['packagecache', 'packagefiles']: continue fname = os.path.join(self.subdir_root, i) - wrap = PackageDefinition(fname) + wrap = PackageDefinition(fname, self.subproject) self.wraps[wrap.name] = wrap for wrap in self.wraps.values(): @@ -271,8 +280,7 @@ class Resolver: return wrap.name return None - def resolve(self, packagename: str, method: str, current_subproject: str = '') -> str: - self.current_subproject = current_subproject + def resolve(self, packagename: str, method: str) -> str: self.packagename = packagename self.directory = packagename self.wrap = self.wraps.get(packagename) @@ -554,8 +562,6 @@ class Resolver: self.download(what, cache_path) return cache_path else: - from ..interpreterbase import FeatureNew - FeatureNew(f'Local wrap patch files without {what}_url', '0.55.0').use(self.current_subproject) path = Path(self.wrap.filesdir) / filename if not path.exists(): @@ -577,8 +583,6 @@ class Resolver: shutil.unpack_archive(path, workdir) self.copy_tree(workdir, self.subdir_root) elif 'patch_directory' in self.wrap.values: - from ..interpreterbase import FeatureNew - FeatureNew('patch_directory', '0.55.0').use(self.current_subproject) patch_dir = self.wrap.values['patch_directory'] src_dir = os.path.join(self.wrap.filesdir, patch_dir) if not os.path.isdir(src_dir): |