From 204fe3c5772f3f6ec9583fb9216412a4eb6018b9 Mon Sep 17 00:00:00 2001 From: Charles Brunet Date: Thu, 7 Sep 2023 14:46:11 -0400 Subject: Fix include_directories test for relative path - On Windows, it was not detected if include directory was an absolute path to source directory, because of the mis of path separators. - In the edgecase the include directory begins with the exact same string as the source directory, but is a different directory, it was falsely reported as an error. Fixes #12217. --- mesonbuild/interpreter/interpreter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 5657b20..d9a260c 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -25,7 +25,7 @@ from ..wrap import wrap, WrapMode from .. import mesonlib from ..mesonlib import (EnvironmentVariables, ExecutableSerialisation, MesonBugException, MesonException, HoldableObject, FileMode, MachineChoice, OptionKey, listify, - extract_as_list, has_path_sep, PerMachine) + extract_as_list, has_path_sep, path_is_in_root, PerMachine) from ..programs import ExternalProgram, NonExistingExternalProgram from ..dependencies import Dependency from ..depfile import DepFile @@ -551,7 +551,7 @@ class Interpreter(InterpreterBase, HoldableObject): if f.is_built: return f = os.path.normpath(f.relative_name()) - elif os.path.isfile(f) and not f.startswith('/dev'): + elif os.path.isfile(f) and not f.startswith('/dev/'): srcdir = Path(self.environment.get_source_dir()) builddir = Path(self.environment.get_build_dir()) try: @@ -2773,7 +2773,7 @@ class Interpreter(InterpreterBase, HoldableObject): absbase_build = os.path.join(build_root, self.subdir) for a in incdir_strings: - if a.startswith(src_root): + if path_is_in_root(Path(a), Path(src_root)): raise InvalidArguments(textwrap.dedent('''\ Tried to form an absolute path to a dir in the source tree. You should not do that but use relative paths instead, for -- cgit v1.1