aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Weißmann <volker.weissmann@gmx.de>2022-06-29 18:38:02 +0200
committerDaniel Mensinger <daniel@mensinger-ka.de>2022-07-18 13:46:26 +0200
commitcdd2dca17491dddafbed1225b2d6471f4eab0535 (patch)
treefd7a9ba4cf54c99a00ba5b7b8fa9248cb2b46c90
parent0bf66ff02c4e89cf3875206c2bf04851340255b4 (diff)
downloadmeson-cdd2dca17491dddafbed1225b2d6471f4eab0535.zip
meson-cdd2dca17491dddafbed1225b2d6471f4eab0535.tar.gz
meson-cdd2dca17491dddafbed1225b2d6471f4eab0535.tar.bz2
cmake module: Better warnings and error messages in some cases.
-rw-r--r--mesonbuild/cmake/generator.py2
-rw-r--r--mesonbuild/cmake/interpreter.py1
-rw-r--r--mesonbuild/cmake/traceparser.py7
3 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/cmake/generator.py b/mesonbuild/cmake/generator.py
index b68778d..f274bce 100644
--- a/mesonbuild/cmake/generator.py
+++ b/mesonbuild/cmake/generator.py
@@ -13,6 +13,7 @@
# limitations under the License.
from .. import mesonlib
+from .. import mlog
from .common import cmake_is_debug
import typing as T
@@ -66,6 +67,7 @@ def parse_generator_expressions(
def target_file(arg: str) -> str:
if arg not in trace.targets:
+ mlog.warning(f"Somewhere in your CMakeLists.txt you have '$<TARGET_FILE:{arg}>'. In cmake, this evaluates to the path to '{arg}'. If '{arg}' does not exist, cmake errors out. We think that '{arg}' does not exist, so we do not know its path and just return an empty string.")
return ''
tgt = trace.targets[arg]
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index 88ab13f..d22b572 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -667,6 +667,7 @@ class ConverterCustomTarget:
commands = [] # type: T.List[T.List[T.Union[str, ConverterTarget]]]
for curr_cmd in self._raw_target.command:
assert isinstance(curr_cmd, list)
+ assert curr_cmd[0] != '', "An empty string is not a valid executable"
cmd = [] # type: T.List[T.Union[str, ConverterTarget]]
for j in curr_cmd:
diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py
index 4dc09ff..e841c7a 100644
--- a/mesonbuild/cmake/traceparser.py
+++ b/mesonbuild/cmake/traceparser.py
@@ -231,7 +231,14 @@ class CMakeTraceParser:
for ctgt in self.custom_targets:
ctgt.outputs = pathlist_gen(ctgt._outputs_str)
+ temp = ctgt.command
ctgt.command = [strlist_gen(x) for x in ctgt.command]
+ for command, src in zip(ctgt.command, temp):
+ if command[0] == "":
+ raise CMakeException(
+ "We have a problem: We would like to generate a recipe for a target that should be generated by the custom command %s\nThe problem is that the executable that should be called, here: '%s', is a variable that evaluates to an empty string. An empty string is not a valid path to an executable so ninja will not be able to call it."
+ % (repr(src), src[0])
+ )
ctgt.working_dir = Path(parse_generator_expressions(str(ctgt.working_dir), self)) if ctgt.working_dir is not None else None
# Postprocess