interpreter: clean up handling of force_fallback

Force_fallback is not an interpreter keyword argument, and there
is no reason to handle it as one since it is not used anywhere
else (and in fact is explicitly ignored by get_dep_identifier).
Use a Python keyword argument instead, which makes the code
simpler.
pull/7740/head
Paolo Bonzini 4 years ago
parent 862bc146a8
commit 1eec5cf41f
  1. 2
      mesonbuild/dependencies/base.py
  2. 25
      mesonbuild/interpreter.py

@ -2322,7 +2322,7 @@ def get_dep_identifier(name, kwargs) -> T.Tuple:
# 'required' is irrelevant for caching; the caller handles it separately
# 'fallback' subprojects cannot be cached -- they must be initialized
# 'default_options' is only used in fallback case
if key in ('version', 'native', 'required', 'fallback', 'default_options', 'force_fallback'):
if key in ('version', 'native', 'required', 'fallback', 'default_options'):
continue
# All keyword arguments are strings, ints, or lists (or lists of lists)
if isinstance(value, list):

@ -2642,10 +2642,9 @@ class Interpreter(InterpreterBase):
FeatureNew.single_use('stdlib without variable name', '0.56.0', self.subproject)
kwargs = {'fallback': di,
'native': for_machine is MachineChoice.BUILD,
'force_fallback': True,
}
name = display_name = l + '_stdlib'
dep = self.dependency_impl(name, display_name, kwargs)
dep = self.dependency_impl(name, display_name, kwargs, force_fallback=True)
self.build.stdlibs[for_machine][l] = dep
def import_module(self, modname):
@ -3701,7 +3700,7 @@ external dependencies (including libraries) must go to "dependencies".''')
build.DependencyOverride(d.held_object, node, explicit=False)
return d
def dependency_impl(self, name, display_name, kwargs):
def dependency_impl(self, name, display_name, kwargs, force_fallback=False):
disabled, required, feature = extract_required_kwarg(kwargs, self.subproject)
if disabled:
mlog.log('Dependency', mlog.bold(display_name), 'skipped: feature', mlog.bold(feature), 'disabled')
@ -3743,21 +3742,21 @@ external dependencies (including libraries) must go to "dependencies".''')
raise DependencyException(m.format(display_name))
return DependencyHolder(cached_dep, self.subproject)
# If the dependency has already been configured, possibly by
# a higher level project, try to use it first.
if fallback:
# If the dependency has already been configured, possibly by
# a higher level project, try to use it first.
dirname, varname = self.get_subproject_infos(fallback)
if self.get_subproject(dirname):
return self.get_subproject_dep(name, display_name, dirname, varname, kwargs)
wrap_mode = self.coredata.get_builtin_option('wrap_mode')
force_fallback_for = self.coredata.get_builtin_option('force_fallback_for')
force_fallback = kwargs.get('force_fallback', False)
forcefallback = fallback and (wrap_mode == WrapMode.forcefallback or \
name in force_fallback_for or \
dirname in force_fallback_for or \
force_fallback)
if name != '' and not forcefallback:
wrap_mode = self.coredata.get_builtin_option('wrap_mode')
force_fallback_for = self.coredata.get_builtin_option('force_fallback_for')
force_fallback = (force_fallback or
wrap_mode == WrapMode.forcefallback or
name in force_fallback_for or
dirname in force_fallback_for)
if name != '' and (not fallback or not force_fallback):
self._handle_featurenew_dependencies(name)
kwargs['required'] = required and not fallback
dep = dependencies.find_external_dependency(name, self.environment, kwargs)

Loading…
Cancel
Save