Skip to content

Commit 4f1c618

Browse files
committed
intepreter: Move remaining PCH validation to Interpreter
1 parent 6198aaa commit 4f1c618

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

mesonbuild/build.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,12 +1591,8 @@ def check_can_link_together(self, t: BuildTargetTypes) -> None:
15911591
mlog.warning(msg + ' This will fail in cross build.')
15921592

15931593
def add_pch(self, language: str, pchlist: T.List[str]) -> None:
1594-
if not pchlist:
1595-
return
1596-
for f in pchlist:
1597-
if not os.path.isfile(os.path.join(self.environment.source_dir, self.subdir, f)):
1598-
raise MesonException(f'File {f} does not exist.')
1599-
self.pch[language] = pchlist
1594+
if pchlist:
1595+
self.pch[language] = pchlist
16001596

16011597
def add_include_dirs(self, args: T.Sequence['IncludeDirs'], set_is_system: T.Optional[str] = None) -> None:
16021598
ids: T.List['IncludeDirs'] = []

mesonbuild/interpreter/interpreter.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
import textwrap
110110
import importlib
111111
import copy
112+
import itertools
112113

113114
if T.TYPE_CHECKING:
114115
from typing_extensions import Literal
@@ -3477,6 +3478,13 @@ def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargs
34773478
if targetclass is not build.Jar:
34783479
self.check_for_jar_sources(sources, targetclass)
34793480
kwargs['d_import_dirs'] = self.extract_incdirs(kwargs, 'd_import_dirs')
3481+
missing: T.List[str] = []
3482+
for each in itertools.chain(kwargs['c_pch'], kwargs['cpp_pch']):
3483+
if each is not None:
3484+
if not os.path.isfile(os.path.join(self.environment.source_dir, self.subdir, each)):
3485+
missing.append(os.path.join(self.subdir, each))
3486+
if missing:
3487+
raise InvalidArguments('The following PCH files do not exist: {}'.format(', '.join(missing)))
34803488

34813489
# Filter out kwargs from other target types. For example 'soversion'
34823490
# passed to library() when default_library == 'static'.

test cases/failing/86 missing pch file/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"stdout": [
33
{
44
"comment": "literal 'pch/prog.h' from meson.build appears in output, irrespective of os.path.sep",
5-
"line": "test cases/failing/86 missing pch file/meson.build:2:6: ERROR: File pch/prog.h does not exist."
5+
"line": "test cases/failing/86 missing pch file/meson.build:2:6: ERROR: The following PCH files do not exist: pch/prog.h, pch/prog_pch.c"
66
}
77
]
88
}

0 commit comments

Comments
 (0)