diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-03-14 20:40:42 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-04-13 17:28:01 -0400 |
commit | df3f064c81cf9053a2ba9fa7b62298de6c5d7625 (patch) | |
tree | c5c4ad73bedb0588687a956270a7bf19945e4d4c /mesonbuild/interpreter/interpreter.py | |
parent | 0e3ed2f6559ff97e4ba85a4d723597017630d150 (diff) | |
download | meson-df3f064c81cf9053a2ba9fa7b62298de6c5d7625.zip meson-df3f064c81cf9053a2ba9fa7b62298de6c5d7625.tar.gz meson-df3f064c81cf9053a2ba9fa7b62298de6c5d7625.tar.bz2 |
dependencies: move DependencyVariableString handling to declare_dependency
This allows tracking which subproject it came from at the time of
definition, rather than the time of use. As a result, it is no longer
possible for one subproject which knows that another subproject installs
some data files, to expose those data files via its own
declare_dependency.
Diffstat (limited to 'mesonbuild/interpreter/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 5bac8ba..bac5f48 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -670,6 +670,18 @@ class Interpreter(InterpreterBase, HoldableObject): d_module_versions = extract_as_list(kwargs, 'd_module_versions') d_import_dirs = self.extract_incdirs(kwargs, 'd_import_dirs') final_deps = [] + srcdir = Path(self.environment.source_dir) + # convert variables which refer to an -uninstalled.pc style datadir + for k, v in variables.items(): + try: + p = Path(v) + except ValueError: + continue + else: + if not self.is_subproject() and srcdir / self.subproject_dir in p.parents: + continue + if p.is_absolute() and p.is_dir() and srcdir / self.root_subdir in p.resolve().parents: + variables[k] = P_OBJ.DependencyVariableString(v) for d in deps: if not isinstance(d, (dependencies.Dependency, dependencies.ExternalLibrary, dependencies.InternalDependency)): raise InterpreterException('Dependencies must be external deps') @@ -2718,8 +2730,9 @@ external dependencies (including libraries) must go to "dependencies".''') @noKwargs def func_join_paths(self, node: mparser.BaseNode, args: T.Tuple[T.List[str]], kwargs: 'TYPE_kwargs') -> str: parts = args[0] + other = os.path.join('', *parts[1:]).replace('\\', '/') ret = os.path.join(*parts).replace('\\', '/') - if isinstance(parts[0], P_OBJ.DependencyVariableString): + if isinstance(parts[0], P_OBJ.DependencyVariableString) and '..' not in other: return P_OBJ.DependencyVariableString(ret) else: return ret @@ -2783,7 +2796,7 @@ Try setting b_lundef to false instead.'''.format(self.coredata.options[OptionKey norm = Path(fname) # variables built from a dep.get_variable are allowed to refer to # subproject files, as long as they are scheduled to be installed. - if norm.is_absolute() and '..' not in norm.parts and validate_installable_file(norm): + if validate_installable_file(norm): return norm = Path(srcdir, subdir, fname).resolve() if os.path.isdir(norm): |