summaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-11-03 10:19:48 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-11-12 08:14:37 -0800
commit20124c8c2711d683e79a79efbc3b7c3e7df414eb (patch)
tree007af4817f9db69c2f5f3a423c9481c57eadbf45 /mesonbuild/interpreter
parent38786d8ac98f53a074008971da8fa328b64806f6 (diff)
downloadmeson-20124c8c2711d683e79a79efbc3b7c3e7df414eb.tar.gz
Interpreter: do basic validation of PCH files in interpeter
This moves the listification and string checking to the interpreter, as well as some basic size validation.
Diffstat (limited to 'mesonbuild/interpreter')
-rw-r--r--mesonbuild/interpreter/kwargs.py2
-rw-r--r--mesonbuild/interpreter/type_checking.py17
2 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py
index 3a301d184..aea24b774 100644
--- a/mesonbuild/interpreter/kwargs.py
+++ b/mesonbuild/interpreter/kwargs.py
@@ -370,6 +370,8 @@ class _BuildTarget(_BaseBuildTarget):
swift_interoperability_mode: Literal['c', 'cpp']
swift_module_name: str
sources: SourcesVarargsType
+ c_pch: T.List[str]
+ cpp_pch: T.List[str]
c_args: T.List[str]
cpp_args: T.List[str]
cuda_args: T.List[str]
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index dc60e2219..700041671 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -652,6 +652,21 @@ _NAME_PREFIX_KW: KwargInfo[T.Optional[T.Union[str, T.List]]] = KwargInfo(
)
+def _pch_validator(args: T.List[str]) -> T.Optional[str]:
+ if len(args) > 2:
+ return 'A maximum of two elements are allowed for PCH arguments'
+ return None
+
+
+_PCH_ARGS: KwargInfo[T.List[str]] = KwargInfo(
+ 'pch',
+ ContainerTypeInfo(list, str),
+ listify=True,
+ default=[],
+ validator=_pch_validator,
+)
+
+
# Applies to all build_target classes except jar
_BUILD_TARGET_KWS: T.List[KwargInfo] = [
*_ALL_TARGET_KWS,
@@ -661,6 +676,8 @@ _BUILD_TARGET_KWS: T.List[KwargInfo] = [
_NAME_PREFIX_KW,
_NAME_PREFIX_KW.evolve(name='name_suffix', validator=_name_suffix_validator),
RUST_CRATE_TYPE_KW,
+ _PCH_ARGS.evolve(name='c_pch'),
+ _PCH_ARGS.evolve(name='cpp_pch'),
KwargInfo('d_debug', ContainerTypeInfo(list, (str, int)), default=[], listify=True),
D_MODULE_VERSIONS_KW,
KwargInfo('d_unittest', bool, default=False),