summaryrefslogtreecommitdiff
path: root/mesonbuild/backend/xcodebackend.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-11-03 11:04:35 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-11-12 08:14:37 -0800
commit176c6d27e3e84f884df42cff6813cc5ca77f91c8 (patch)
tree04ce87d3666b01ec8d949e5d4c3d0d0446ee51e2 /mesonbuild/backend/xcodebackend.py
parent4f1c618392972c935d83eb7939234b3b90479df5 (diff)
downloadmeson-176c6d27e3e84f884df42cff6813cc5ca77f91c8.tar.gz
build: Use a tuple for pch data
This really isn't a list because it's not homogenous data, it's really `tuple[str, str | None] | None`, but we're using list length to decide what to do with it, and that makes for strict null issues, as an accurate annotation would be `list[str | None]`, which would require a lot of `is not None` checking. By using a tuple we don't need to keep checking length, which is more expensive than null checking. To ensure correctness I annotated some things in the VS backend
Diffstat (limited to 'mesonbuild/backend/xcodebackend.py')
-rw-r--r--mesonbuild/backend/xcodebackend.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 87e1309a6..95a62a02a 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -1802,9 +1802,7 @@ class XCodeBackend(backends.Backend):
# Xcode uses GCC_PREFIX_HEADER which only allows one file per target/executable. Precompiling various header files and
# applying a particular pch to each source file will require custom scripts (as a build phase) and build flags per each
# file. Since Xcode itself already discourages precompiled headers in favor of modules we don't try much harder here.
- pchs = target.get_pch('c') + target.get_pch('cpp') + target.get_pch('objc') + target.get_pch('objcpp')
- # Make sure to use headers (other backends require implementation files like *.c *.cpp, etc; these should not be used here)
- pchs = [pch for pch in pchs if pch.endswith('.h') or pch.endswith('.hh') or pch.endswith('hpp')]
+ pchs = [t[0] for t in [target.pch['c'], target.pch['cpp']] if t is not None]
if pchs:
if len(pchs) > 1:
mlog.warning(f'Unsupported Xcode configuration: More than 1 precompiled header found "{pchs!s}". Target "{target.name}" might not compile correctly.')