aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2021-11-28 12:06:19 +0100
committerDaniel Mensinger <daniel@mensinger-ka.de>2022-01-23 13:22:47 +0100
commit99aae9b4dfc7f1ab6469adee718d54d9afd45097 (patch)
tree71a3fa6d01b0b81122e86e43987cad72117c15d5 /mesonbuild
parentbaff6bccac5f4f476033276bed8a9cc3cb3c5a15 (diff)
downloadmeson-99aae9b4dfc7f1ab6469adee718d54d9afd45097.zip
meson-99aae9b4dfc7f1ab6469adee718d54d9afd45097.tar.gz
meson-99aae9b4dfc7f1ab6469adee718d54d9afd45097.tar.bz2
cmake: Move generator expression evaluation to the end of the traceparser
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/cmake/generator.py5
-rw-r--r--mesonbuild/cmake/traceparser.py33
2 files changed, 35 insertions, 3 deletions
diff --git a/mesonbuild/cmake/generator.py b/mesonbuild/cmake/generator.py
index 848fdf9..6525bcb 100644
--- a/mesonbuild/cmake/generator.py
+++ b/mesonbuild/cmake/generator.py
@@ -15,7 +15,10 @@
from .. import mesonlib
import typing as T
-def parse_generator_expressions(raw: str) -> str:
+if T.TYPE_CHECKING:
+ from .traceparser import CMakeTraceParser
+
+def parse_generator_expressions(raw: str, trace: 'CMakeTraceParser') -> str:
'''Parse CMake generator expressions
Most generator expressions are simply ignored for
diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py
index 66dd4ef..fd7e115 100644
--- a/mesonbuild/cmake/traceparser.py
+++ b/mesonbuild/cmake/traceparser.py
@@ -183,6 +183,37 @@ class CMakeTraceParser:
if fn:
fn(l)
+ # Evaluate generator expressions
+ strlist_gen: T.Callable[[T.List[str]], T.List[str]] = lambda strlist: [parse_generator_expressions(x, self) for x in strlist]
+ pathlist_gen: T.Callable[[T.List[Path]], T.List[Path]] = lambda plist: [Path(parse_generator_expressions(str(x), self)) for x in plist]
+
+ self.vars = {k: strlist_gen(v) for k, v in self.vars.items()}
+ self.vars_by_file = {
+ p: {k: strlist_gen(v) for k, v in d.items()}
+ for p, d in self.vars_by_file.items()
+ }
+ self.explicit_headers = set(Path(parse_generator_expressions(str(x), self)) for x in self.explicit_headers)
+ self.cache = {
+ k: CMakeCacheEntry(
+ strlist_gen(v.value),
+ v.type
+ )
+ for k, v in self.cache.items()
+ }
+
+ for tgt in self.targets.values():
+ tgt.name = parse_generator_expressions(tgt.name, self)
+ tgt.type = parse_generator_expressions(tgt.type, self)
+ tgt.properties = {
+ k: strlist_gen(v) for k, v in tgt.properties.items()
+ } if tgt.properties is not None else None
+ tgt.depends = strlist_gen(tgt.depends)
+
+ for ctgt in self.custom_targets:
+ ctgt.outputs = pathlist_gen(ctgt.outputs)
+ ctgt.command = [strlist_gen(x) for x in ctgt.command]
+ ctgt.working_dir = Path(parse_generator_expressions(str(ctgt.working_dir), self)) if ctgt.working_dir is not None else None
+
# Postprocess
for tgt in self.targets.values():
tgt.strip_properties()
@@ -676,7 +707,6 @@ class CMakeTraceParser:
line = mo_file_line.group(3)
func = mo_file_line.group(4)
args = mo_file_line.group(5)
- args = parse_generator_expressions(args)
argl = args.split(' ')
argl = list(map(lambda x: x.strip(), argl))
@@ -694,7 +724,6 @@ class CMakeTraceParser:
args = data['args']
for j in args:
assert isinstance(j, str)
- args = [parse_generator_expressions(x) for x in args]
yield CMakeTraceLine(data['file'], data['line'], data['cmd'], args)
def _flatten_args(self, args: T.List[str]) -> T.List[str]: