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. 19
      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 # 'required' is irrelevant for caching; the caller handles it separately
# 'fallback' subprojects cannot be cached -- they must be initialized # 'fallback' subprojects cannot be cached -- they must be initialized
# 'default_options' is only used in fallback case # '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 continue
# All keyword arguments are strings, ints, or lists (or lists of lists) # All keyword arguments are strings, ints, or lists (or lists of lists)
if isinstance(value, list): if isinstance(value, list):

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

Loading…
Cancel
Save