diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-10-27 10:01:02 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-12-17 14:47:18 -0800 |
| commit | 195dab0ea81986fe8cdcec6072fa67f978af3135 (patch) | |
| tree | f88c4f93b0379027396f7ae1463ad92f352d57bd | |
| parent | c335eeae504cbcee2d27604232dc7e8b7e4d3caa (diff) | |
| download | meson-195dab0ea81986fe8cdcec6072fa67f978af3135.tar.gz | |
dependencies/detect: simplify logging tried methods
Avoid extra method calls and repeating ourselves.
| -rw-r--r-- | mesonbuild/dependencies/detect.py | 16 | ||||
| -rw-r--r-- | test cases/failing/100 no fallback/test.json | 2 | ||||
| -rw-r--r-- | test cases/failing/33 dependency not-required then required/test.json | 2 | ||||
| -rw-r--r-- | test cases/failing/62 wrong boost module/test.json | 2 | ||||
| -rw-r--r-- | test cases/failing/79 dub library/test.json | 2 | ||||
| -rw-r--r-- | test cases/failing/80 dub executable/test.json | 2 | ||||
| -rw-r--r-- | test cases/failing/81 dub compiler/test.json | 2 |
7 files changed, 11 insertions, 17 deletions
diff --git a/mesonbuild/dependencies/detect.py b/mesonbuild/dependencies/detect.py index 97eeb21cd..65e19c2aa 100644 --- a/mesonbuild/dependencies/detect.py +++ b/mesonbuild/dependencies/detect.py @@ -112,6 +112,7 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: DependencyOb pkg_exc: T.List[DependencyException] = [] pkgdep: T.List[ExternalDependency] = [] details = '' + tried_methods: T.List[str] = [] for c in candidates: # try this dependency method @@ -139,7 +140,6 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: DependencyOb # if the dependency was found if d.found(): - info: mlog.TV_LoggableList = [] if d.version: info.append(mlog.normal_cyan(d.version)) @@ -151,16 +151,11 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: DependencyOb mlog.log(type_text, mlog.bold(display_name), details + 'found:', mlog.green('YES'), *info) return d + tried_methods.append(c.method) # otherwise, the dependency could not be found - tried_methods = [d.log_tried() for d in pkgdep if d.log_tried()] - if tried_methods: - tried = mlog.format_list(tried_methods) - else: - tried = '' - - mlog.log(type_text, mlog.bold(display_name), details + 'found:', mlog.red('NO'), - f'(tried {tried})' if tried else '') + tried = ' (tried {})'.format(mlog.format_list(tried_methods)) if tried_methods else '' + mlog.log(type_text, mlog.bold(display_name), details + 'found:', mlog.red('NO'), tried) if required: # if an exception occurred with the first detection method, re-raise it @@ -171,8 +166,7 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: DependencyOb # we have a list of failed ExternalDependency objects, so we can report # the methods we tried to find the dependency - raise DependencyException(f'Dependency "{name}" not found' + - (f', tried {tried}' if tried else '')) + raise DependencyException(f'Dependency "{name}" not found' + tried) return NotFoundDependency(name, env) diff --git a/test cases/failing/100 no fallback/test.json b/test cases/failing/100 no fallback/test.json index 5fbffe35d..d3f7345b0 100644 --- a/test cases/failing/100 no fallback/test.json +++ b/test cases/failing/100 no fallback/test.json @@ -2,7 +2,7 @@ "stdout": [ { "match": "re", - "line": ".*/meson\\.build:2:11: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foob\" not found, tried .*)" + "line": ".*/meson\\.build:2:11: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foob\" not found \\(tried .*\\))" } ] } diff --git a/test cases/failing/33 dependency not-required then required/test.json b/test cases/failing/33 dependency not-required then required/test.json index 7dd851956..daf4f351a 100644 --- a/test cases/failing/33 dependency not-required then required/test.json +++ b/test cases/failing/33 dependency not-required then required/test.json @@ -2,7 +2,7 @@ "stdout": [ { "match": "re", - "line": ".*/meson\\.build:4:10: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foo\\-bar\\-xyz\\-12\\.3\" not found, tried .*)" + "line": ".*/meson\\.build:4:10: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foo\\-bar\\-xyz\\-12\\.3\" not found \\(tried .*\\))" } ] } diff --git a/test cases/failing/62 wrong boost module/test.json b/test cases/failing/62 wrong boost module/test.json index 75ef82b7e..2765ce917 100644 --- a/test cases/failing/62 wrong boost module/test.json +++ b/test cases/failing/62 wrong boost module/test.json @@ -1,7 +1,7 @@ { "stdout": [ { - "line": "test cases/failing/62 wrong boost module/meson.build:9:10: ERROR: Dependency \"boost\" not found, tried system" + "line": "test cases/failing/62 wrong boost module/meson.build:9:10: ERROR: Dependency \"boost\" not found (tried system)" } ] } diff --git a/test cases/failing/79 dub library/test.json b/test cases/failing/79 dub library/test.json index 9f59604a4..ea4e73490 100644 --- a/test cases/failing/79 dub library/test.json +++ b/test cases/failing/79 dub library/test.json @@ -1,7 +1,7 @@ { "stdout": [ { - "line": "test cases/failing/79 dub library/meson.build:11:0: ERROR: Dependency \"dubtestproject\" not found" + "line": "test cases/failing/79 dub library/meson.build:11:0: ERROR: Dependency \"dubtestproject\" not found (tried dub)" } ] } diff --git a/test cases/failing/80 dub executable/test.json b/test cases/failing/80 dub executable/test.json index edb74f62c..97dab9f87 100644 --- a/test cases/failing/80 dub executable/test.json +++ b/test cases/failing/80 dub executable/test.json @@ -1,7 +1,7 @@ { "stdout": [ { - "line": "test cases/failing/80 dub executable/meson.build:11:0: ERROR: Dependency \"dubtestproject:test1\" not found" + "line": "test cases/failing/80 dub executable/meson.build:11:0: ERROR: Dependency \"dubtestproject:test1\" not found (tried dub)" } ] } diff --git a/test cases/failing/81 dub compiler/test.json b/test cases/failing/81 dub compiler/test.json index d82984d5d..1018d478b 100644 --- a/test cases/failing/81 dub compiler/test.json +++ b/test cases/failing/81 dub compiler/test.json @@ -13,7 +13,7 @@ }, "stdout": [ { - "line": "test cases/failing/81 dub compiler/meson.build:17:0: ERROR: Dependency \"dubtestproject:test2\" not found" + "line": "test cases/failing/81 dub compiler/meson.build:17:0: ERROR: Dependency \"dubtestproject:test2\" not found (tried dub)" } ] } |
