From f3b9db9e9d9025d582ecd45107f52acb3bafee8d Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Fri, 4 Aug 2023 17:59:44 +0200 Subject: build.py: improve BuildTarget error message Improve the error message when a build target is assigned as dependency of another build target, which allows to better pinpoint where the issue lies on. In the example that follow, modules/meson.build:294 is in a for loop creating library targets from an array of dictionary, and doesn't point to the location where interop_sw_plugin is assigned with vlc_opengl: Before: modules/meson.build:294:17: ERROR: Tried to use a build target as a dependency. You probably should put it in link_with instead. After: modules/meson.build:294:17: ERROR: Tried to use a build target vlc_opengl as a dependency of target interop_sw_plugin. You probably should put it in link_with instead. It would probably be best to directly pinpoint where the assignment was made but it's probably harder so start simple by saying what is concerned by the error. --- mesonbuild/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 16bf412..d6ca8c1 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1346,8 +1346,8 @@ class BuildTarget(Target): self.process_sourcelist(dep.get_sources()) self.add_deps(dep.ext_deps) elif isinstance(dep, BuildTarget): - raise InvalidArguments('''Tried to use a build target as a dependency. -You probably should put it in link_with instead.''') + raise InvalidArguments(f'Tried to use a build target {dep.name} as a dependency of target {self.name}.\n' + 'You probably should put it in link_with instead.') else: # This is a bit of a hack. We do not want Build to know anything # about the interpreter so we can't import it and use isinstance. -- cgit v1.1