Skip to content

Commit 76c36a6

Browse files
authored
dependency: log cached or skipped dependencies with reference to modules
* dependency: log cached or skipped dependencies with reference to modules If the dependency is a special dependency which takes modules, the modules get cached separately and probably reference different pkg-config files. It's very plausible that we have multiple dependencies, using different modules. For example: Run-time dependency qt5 (modules: Core) found: YES 5.14.2 (pkg-config) Dependency qt5 skipped: feature gui disabled Obviously this makes no sense, because of course we found qt5 and even used it. The second line is a lot more readable if it shows this: Dependency qt5 (modules: Widgets) skipped: feature gui disabled Similar confusion abounds in the case where a module is found in the cache -- which module, exactly, has been found here: Dependency qt5 found: YES 5.14.2 (cached) Rewrite the dependency function to *consistently* pass around (and use!) the display_name even in cases where we know it isn't anonymous (this is just more correct anyway), and make it serve a dual purpose by also appending the list of modules just like we do for pretty-printing that a dependency has just been found for the first time. * fixup! dependency: log cached or skipped dependencies with reference to modules pointlessly cast modules to str, as they cannot be anything else. But we want to fail later on, with something more friendly than a stacktrace. boost/wx have special exceptions for people passing an integer there.
1 parent 39a69d1 commit 76c36a6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mesonbuild/interpreter.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,7 +3282,7 @@ def func_find_library(self, node, args, kwargs):
32823282
'Look here for example: http://mesonbuild.com/howtox.html#add-math-library-lm-portably\n'
32833283
)
32843284

3285-
def _find_cached_dep(self, name, kwargs):
3285+
def _find_cached_dep(self, name, display_name, kwargs):
32863286
# Check if we want this as a build-time / build machine or runt-time /
32873287
# host machine dep.
32883288
for_machine = self.machine_from_native_kwarg(kwargs)
@@ -3297,7 +3297,7 @@ def _find_cached_dep(self, name, kwargs):
32973297
# have explicitly called meson.override_dependency() with a not-found
32983298
# dep.
32993299
if not cached_dep.found():
3300-
mlog.log('Dependency', mlog.bold(name),
3300+
mlog.log('Dependency', mlog.bold(display_name),
33013301
'found:', mlog.red('NO'), *info)
33023302
return identifier, cached_dep
33033303
found_vers = cached_dep.get_version()
@@ -3319,7 +3319,7 @@ def _find_cached_dep(self, name, kwargs):
33193319
if cached_dep:
33203320
if found_vers:
33213321
info = [mlog.normal_cyan(found_vers), *info]
3322-
mlog.log('Dependency', mlog.bold(name),
3322+
mlog.log('Dependency', mlog.bold(display_name),
33233323
'found:', mlog.green('YES'), *info)
33243324
return identifier, cached_dep
33253325

@@ -3352,7 +3352,7 @@ def get_subproject_dep(self, name, display_name, dirname, varname, kwargs):
33523352
dep = self.notfound_dependency()
33533353
try:
33543354
subproject = self.subprojects[dirname]
3355-
_, cached_dep = self._find_cached_dep(name, kwargs)
3355+
_, cached_dep = self._find_cached_dep(name, display_name, kwargs)
33563356
if varname is None:
33573357
# Assuming the subproject overridden the dependency we want
33583358
if cached_dep:
@@ -3425,6 +3425,9 @@ def func_dependency(self, node, args, kwargs):
34253425
self.validate_arguments(args, 1, [str])
34263426
name = args[0]
34273427
display_name = name if name else '(anonymous)'
3428+
mods = extract_as_list(kwargs, 'modules')
3429+
if mods:
3430+
display_name += ' (modules: {})'.format(', '.join(str(i) for i in mods))
34283431
not_found_message = kwargs.get('not_found_message', '')
34293432
if not isinstance(not_found_message, str):
34303433
raise InvalidArguments('The not_found_message must be a string.')
@@ -3466,7 +3469,7 @@ def dependency_impl(self, name, display_name, kwargs):
34663469
raise InvalidArguments('Characters <, > and = are forbidden in dependency names. To specify'
34673470
'version\n requirements use the \'version\' keyword argument instead.')
34683471

3469-
identifier, cached_dep = self._find_cached_dep(name, kwargs)
3472+
identifier, cached_dep = self._find_cached_dep(name, display_name, kwargs)
34703473
if cached_dep:
34713474
if has_fallback:
34723475
dirname, varname = self.get_subproject_infos(kwargs)

0 commit comments

Comments
 (0)