From 3728fc0aeb98a8fe772d6b53b626b004caddb393 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 3 Nov 2025 12:25:00 -0800 Subject: interpreter: move backend type checking to interpreter Of course, this checking isn't actually doing what it claims, as it doesn't actually stop you from writing at target like: ```meson build_target( 'foo', 'srcs/main.c', c_pch : 'src/pch.h', ) ``` --- mesonbuild/backend/ninjabackend.py | 4 ---- mesonbuild/interpreter/type_checking.py | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 90c61a26b..603a512b2 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -3380,10 +3380,6 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) pch = target.pch[lang] if not pch: continue - if not has_path_sep(pch[0]) or (pch[1] and has_path_sep(pch[1])): - msg = f'Precompiled header of {target.get_basename()!r} must not be in the same ' \ - 'directory as source, please put it in a subdirectory.' - raise InvalidArguments(msg) compiler: Compiler = target.compilers[lang] if compiler.get_argument_syntax() == 'msvc': (commands, dep, dst, objs, src) = self.generate_msvc_pch_command(target, compiler, pch) diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 6cd43b7c6..b4799f3a7 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -671,6 +671,10 @@ def _pch_validator(args: T.List[str]) -> T.Optional[str]: return 'PCH files must be stored in the same folder.' elif num_args > 2: return 'A maximum of two elements are allowed for PCH arguments' + if num_args >= 1 and not has_path_sep(args[0]): + return f'PCH header {args[0]} must not be in the same directory as source files' + if num_args == 2 and not has_path_sep(args[1]): + return f'PCH source {args[0]} must not be in the same directory as source files' return None -- cgit v1.2.3