From f15655945ade448baa8c2ce414417493c86c59e2 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 13 Nov 2024 11:22:09 -0500 Subject: [PATCH] dependencies: Improve error message when variable is not found The current error message does not tell which variable is not found and prints internal representation of the dependency object: ERROR: Could not get pkg-config variable and no default provided for --- mesonbuild/dependencies/base.py | 2 +- mesonbuild/dependencies/cmake.py | 2 +- mesonbuild/dependencies/configtool.py | 2 +- mesonbuild/dependencies/pkgconfig.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index ed6138a7ee0b..951dec693f64 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -347,7 +347,7 @@ def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[s val = self.variables.get(internal, default_value) if val is not None: return val - raise DependencyException(f'Could not get an internal variable and no default provided for {self!r}') + raise DependencyException(f'Could not get an internal variable {internal} and no default provided') def generate_link_whole_dependency(self) -> Dependency: from ..build import SharedLibrary, CustomTarget, CustomTargetIndex diff --git a/mesonbuild/dependencies/cmake.py b/mesonbuild/dependencies/cmake.py index 4a722157ff56..0baec27d41d7 100644 --- a/mesonbuild/dependencies/cmake.py +++ b/mesonbuild/dependencies/cmake.py @@ -637,7 +637,7 @@ def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[s return ';'.join(v) if default_value is not None: return default_value - raise DependencyException(f'Could not get cmake variable and no default provided for {self!r}') + raise DependencyException(f'Could not get {self.name} cmake variable {cmake} and no default provided') class CMakeDependencyFactory: diff --git a/mesonbuild/dependencies/configtool.py b/mesonbuild/dependencies/configtool.py index 476f7ad420aa..ea7b33d44955 100644 --- a/mesonbuild/dependencies/configtool.py +++ b/mesonbuild/dependencies/configtool.py @@ -170,4 +170,4 @@ def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[s return variable if default_value is not None: return default_value - raise DependencyException(f'Could not get config-tool variable and no default provided for {self!r}') + raise DependencyException(f'Could not get {self.name} variable {configtool} using {self.tool_name} and no default provided') diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py index c6e6a5e4f2ca..dba13637ca9d 100644 --- a/mesonbuild/dependencies/pkgconfig.py +++ b/mesonbuild/dependencies/pkgconfig.py @@ -586,4 +586,4 @@ def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[s pass if default_value is not None: return default_value - raise DependencyException(f'Could not get pkg-config variable and no default provided for {self!r}') + raise DependencyException(f'Could not get {self.name} pkg-config variable {pkgconfig} and no default provided')