diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-08-29 19:31:38 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-09-12 19:16:59 -0400 |
commit | 719dd0d2a04592812194e8588279827ec52fc92e (patch) | |
tree | 2377d9867c777d0262a34c249c0cc3c7f0c30b3d | |
parent | b821a0351136b3b3872e2ba9da8f7c67c4275449 (diff) | |
download | meson-719dd0d2a04592812194e8588279827ec52fc92e.zip meson-719dd0d2a04592812194e8588279827ec52fc92e.tar.gz meson-719dd0d2a04592812194e8588279827ec52fc92e.tar.bz2 |
dependencies: log the real reason for a dependency lookup failing
In the debug logs, always log if a dependency lookup raises a
DependencyException. In the `required: false` case, this information
would otherwise disappear forever, and we would just not even log that
we tried it -- it doesn't appear in "(tried x, y and z)".
In the `required: true` case, we would re-raise the first exception if
it failed to be detected. Update the raise message with the same
information we print to the debug logs, indicating which dependency and
which method was used in the failing attempt.
5 files changed, 9 insertions, 6 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index afe70c7..d901ef9 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -406,7 +406,7 @@ class ExternalDependency(Dependency, HasNativeKwarg): mlog.log(*found_msg) if self.required: - m = f'Unknown version of dependency {self.name!r}, but need {self.version_reqs!r}.' + m = f'Unknown version, but need {self.version_reqs!r}.' raise DependencyException(m) else: @@ -423,7 +423,7 @@ class ExternalDependency(Dependency, HasNativeKwarg): mlog.log(*found_msg) if self.required: - m = 'Invalid version of dependency, need {!r} {!r} found {!r}.' + m = 'Invalid version, need {!r} {!r} found {!r}.' raise DependencyException(m.format(self.name, not_found, self.version)) return diff --git a/mesonbuild/dependencies/detect.py b/mesonbuild/dependencies/detect.py index 6e7d6d9..ebbcc2f 100644 --- a/mesonbuild/dependencies/detect.py +++ b/mesonbuild/dependencies/detect.py @@ -113,8 +113,11 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: T.Dict[str, d._check_version() pkgdep.append(d) except DependencyException as e: + assert isinstance(c, functools.partial), 'for mypy' + bettermsg = f'Dependency lookup for {name} with method {c.func.log_tried()!r} failed: {e}' + mlog.debug(bettermsg) + e.args = (bettermsg,) pkg_exc.append(e) - mlog.debug(str(e)) else: pkg_exc.append(None) details = d.log_details() diff --git a/test cases/failing/78 framework dependency with version/test.json b/test cases/failing/78 framework dependency with version/test.json index c9f25a2..d43a498 100644 --- a/test cases/failing/78 framework dependency with version/test.json +++ b/test cases/failing/78 framework dependency with version/test.json @@ -1,7 +1,7 @@ { "stdout": [ { - "line": "test cases/failing/78 framework dependency with version/meson.build:8:0: ERROR: Unknown version of dependency 'appleframeworks', but need ['>0']." + "line": "test cases/failing/78 framework dependency with version/meson.build:8:0: ERROR: Dependency lookup for appleframeworks with method 'framework' failed: Unknown version, but need ['>0']." } ] } diff --git a/test cases/failing/80 gl dependency with version/test.json b/test cases/failing/80 gl dependency with version/test.json index cae10da..3d39bc3 100644 --- a/test cases/failing/80 gl dependency with version/test.json +++ b/test cases/failing/80 gl dependency with version/test.json @@ -1,7 +1,7 @@ { "stdout": [ { - "line": "test cases/failing/80 gl dependency with version/meson.build:9:0: ERROR: Unknown version of dependency 'gl', but need ['>0']." + "line": "test cases/failing/80 gl dependency with version/meson.build:9:0: ERROR: Dependency lookup for gl with method 'system' failed: Unknown version, but need ['>0']." } ] } diff --git a/test cases/failing/81 threads dependency with version/test.json b/test cases/failing/81 threads dependency with version/test.json index 7781b72..308ac66 100644 --- a/test cases/failing/81 threads dependency with version/test.json +++ b/test cases/failing/81 threads dependency with version/test.json @@ -1,7 +1,7 @@ { "stdout": [ { - "line": "test cases/failing/81 threads dependency with version/meson.build:3:0: ERROR: Unknown version of dependency 'threads', but need ['>0']." + "line": "test cases/failing/81 threads dependency with version/meson.build:3:0: ERROR: Dependency lookup for threads with method 'system' failed: Unknown version, but need ['>0']." } ] } |