aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake/traceparser.py
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2020-01-08 17:06:58 +0100
committerDaniel Mensinger <daniel@mensinger-ka.de>2020-01-26 18:23:34 +0100
commit3607f50d7f5bfa33806a4ed48d4fb773f35ee537 (patch)
treeeb9bcf2554f4c3ea879f1057d82e920cc963d5b1 /mesonbuild/cmake/traceparser.py
parentb74ece344fe6d40e1040670a12be1dde3adb71b2 (diff)
downloadmeson-3607f50d7f5bfa33806a4ed48d4fb773f35ee537.zip
meson-3607f50d7f5bfa33806a4ed48d4fb773f35ee537.tar.gz
meson-3607f50d7f5bfa33806a4ed48d4fb773f35ee537.tar.bz2
cmake: Refactor CMakeExecutor and CMakeTraceParser
This moves most of the execution code from the CMakeInterpreter into CMakeExecutor. Also, CMakeTraceParser is now responsible for determining the trace cmd arguments.
Diffstat (limited to 'mesonbuild/cmake/traceparser.py')
-rw-r--r--mesonbuild/cmake/traceparser.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py
index ceb5b02..cdaeb3d 100644
--- a/mesonbuild/cmake/traceparser.py
+++ b/mesonbuild/cmake/traceparser.py
@@ -18,8 +18,10 @@
from .common import CMakeException
from .generator import parse_generator_expressions
from .. import mlog
+from ..mesonlib import version_compare
import typing as T
+from pathlib import Path
import re
import os
@@ -60,7 +62,7 @@ class CMakeGeneratorTarget(CMakeTarget):
self.working_dir = None # type: T.Optional[str]
class CMakeTraceParser:
- def __init__(self, permissive: bool = False):
+ def __init__(self, cmake_version: str, build_dir: str, permissive: bool = False):
# Dict of CMake variables: '<var_name>': ['list', 'of', 'values']
self.vars = {}
@@ -71,10 +73,27 @@ class CMakeTraceParser:
self.custom_targets = [] # type: T.List[CMakeGeneratorTarget]
self.permissive = permissive # type: bool
+ self.cmake_version = cmake_version # type: str
+ self.trace_format = 'human'
- def parse(self, trace: str) -> None:
- # First parse the trace
- lexer1 = self._lex_trace(trace)
+ def trace_args(self) -> T.List[str]:
+ arg_map = {
+ 'human': ['--trace', '--trace-expand'],
+ }
+
+ base_args = ['--no-warn-unused-cli']
+ return arg_map[self.trace_format] + base_args
+
+ def parse(self, trace: T.Optional[str] = None) -> None:
+ if not trace:
+ raise CMakeException('CMake: The CMake trace was not provided or is empty')
+
+ # Second parse the trace
+ lexer1 = None
+ if self.trace_format == 'human':
+ lexer1 = self._lex_trace_human(trace)
+ else:
+ raise CMakeException('CMake: Internal error: Invalid trace format {}. Expected [human]'.format(self.trace_format))
# All supported functions
functions = {
@@ -481,7 +500,7 @@ class CMakeTraceParser:
self.targets[target].properties[i[0]] += i[1]
- def _lex_trace(self, trace):
+ def _lex_trace_human(self, trace):
# The trace format is: '<file>(<line>): <func>(<args -- can contain \n> )\n'
reg_tline = re.compile(r'\s*(.*\.(cmake|txt))\(([0-9]+)\):\s*(\w+)\(([\s\S]*?) ?\)\s*\n', re.MULTILINE)
reg_other = re.compile(r'[^\n]*\n')
@@ -510,7 +529,7 @@ class CMakeTraceParser:
yield CMakeTraceLine(file, line, func, args)
def _guess_files(self, broken_list: T.List[str]) -> T.List[str]:
- #Try joining file paths that contain spaces
+ # Try joining file paths that contain spaces
reg_start = re.compile(r'^([A-Za-z]:)?/.*/[^./]+$')
reg_end = re.compile(r'^.*\.[a-zA-Z]+$')