Skip to content

Commit

Permalink
dependencies: Improve error message when variable is not found
Browse files Browse the repository at this point in the history
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 <PkgConfigDependency glib-2.0: True None>
  • Loading branch information
xclaesse committed Nov 13, 2024
1 parent b3f9b9d commit f156559
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mesonbuild/dependencies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/dependencies/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/dependencies/configtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
2 changes: 1 addition & 1 deletion mesonbuild/dependencies/pkgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit f156559

Please sign in to comment.