diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2025-03-07 10:18:24 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2025-04-24 17:52:13 +0300 |
commit | fc9fd42899e1e2160a69ec245931c3aa79b0d267 (patch) | |
tree | 7a652d752490109669b6915f83d826d6a34d7e9d /mesonbuild | |
parent | 475bfba79a1a65d85e880a44fd995fc4aaf0c8c4 (diff) | |
download | meson-fc9fd42899e1e2160a69ec245931c3aa79b0d267.zip meson-fc9fd42899e1e2160a69ec245931c3aa79b0d267.tar.gz meson-fc9fd42899e1e2160a69ec245931c3aa79b0d267.tar.bz2 |
interpreter: do not use pathlib for DependencyVariableString creation
Path.is_dir() can raise a PermissionError if a parent does not have
the executable permission set; plus the "in p.parents" tests are
very expensive. Do not use Path at all.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 185bb07..bf41bfb 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -704,20 +704,18 @@ class Interpreter(InterpreterBase, HoldableObject): version = self.project_version d_module_versions = kwargs['d_module_versions'] d_import_dirs = self.extract_incdirs(kwargs, 'd_import_dirs') - srcdir = Path(self.environment.source_dir) + srcdir = self.environment.source_dir + subproject_dir = os.path.abspath(os.path.join(srcdir, self.subproject_dir)) + project_root = os.path.abspath(os.path.join(srcdir, self.root_subdir)) # convert variables which refer to an -uninstalled.pc style datadir for k, v in variables.items(): if not v: FeatureNew.single_use('empty variable value in declare_dependency', '1.4.0', self.subproject, location=node) - 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] + list(Path(os.path.abspath(p)).parents): - variables[k] = P_OBJ.DependencyVariableString(v) + if os.path.isabs(v) \ + and (self.is_subproject() or not is_parent_path(subproject_dir, v)) \ + and is_parent_path(project_root, v) \ + and os.path.isdir(v): + variables[k] = P_OBJ.DependencyVariableString(v) dep = dependencies.InternalDependency(version, incs, compile_args, link_args, libs, libs_whole, sources, extra_files, |