aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake/traceparser.py
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2022-04-03 13:06:10 +0200
committerEli Schwartz <eschwartz93@gmail.com>2022-04-03 12:04:21 -0400
commit4dd6cb846900bf827c257f830d54d9fd0932743e (patch)
tree3151f6f9cff2e102635c883b59fb78bc4595a457 /mesonbuild/cmake/traceparser.py
parent2c4c7f6e64c923976158051cae8c63ee1364d573 (diff)
downloadmeson-4dd6cb846900bf827c257f830d54d9fd0932743e.zip
meson-4dd6cb846900bf827c257f830d54d9fd0932743e.tar.gz
meson-4dd6cb846900bf827c257f830d54d9fd0932743e.tar.bz2
cmake: Better error message when configuring a CMake subproject fails.
Diffstat (limited to 'mesonbuild/cmake/traceparser.py')
-rw-r--r--mesonbuild/cmake/traceparser.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py
index 7336d15..967b40a 100644
--- a/mesonbuild/cmake/traceparser.py
+++ b/mesonbuild/cmake/traceparser.py
@@ -111,6 +111,8 @@ class CMakeTraceParser:
self.trace_file_path = build_dir / self.trace_file
self.trace_format = 'json-v1' if version_compare(cmake_version, '>=3.17') else 'human'
+ self.errors: T.List[str] = []
+
# State for delayed command execution. Delayed command execution is realised
# with a custom CMake file that overrides some functions and adds some
# introspection information to the trace.
@@ -133,6 +135,7 @@ class CMakeTraceParser:
'target_link_libraries': self._cmake_target_link_libraries,
'target_link_options': self._cmake_target_link_options,
'add_dependencies': self._cmake_add_dependencies,
+ 'message': self._cmake_message,
# Special functions defined in the preload script.
# These functions do nothing in the CMake code, but have special
@@ -639,6 +642,18 @@ class CMakeTraceParser:
# DOC: https://cmake.org/cmake/help/latest/command/target_link_libraries.html
self._parse_common_target_options('target_link_options', 'LINK_LIBRARIES', 'INTERFACE_LINK_LIBRARIES', tline)
+ def _cmake_message(self, tline: CMakeTraceLine) -> None:
+ # DOC: https://cmake.org/cmake/help/latest/command/message.html
+ args = list(tline.args)
+
+ if len(args) < 1:
+ return self._gen_exception('message', 'takes at least 1 argument', tline)
+
+ if args[0].upper().strip() not in ['FATAL_ERROR', 'SEND_ERROR']:
+ return
+
+ self.errors += [' '.join(args[1:])]
+
def _parse_common_target_options(self, func: str, private_prop: str, interface_prop: str, tline: CMakeTraceLine, ignore: T.Optional[T.List[str]] = None, paths: bool = False) -> None:
if ignore is None:
ignore = ['BEFORE']