Bug 1296530 - Move the somehow redundant check for --help dependency from _resolve to _value_for_depends. r?chmanchester
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -312,53 +312,52 @@ class ConfigureSandbox(dict):
not (inspect.isclass(value) and issubclass(value, Exception))):
raise KeyError('Cannot assign `%s` because it is neither a '
'@depends nor a @template' % key)
return super(ConfigureSandbox, self).__setitem__(key, value)
def _resolve(self, arg, need_help_dependency=True):
if isinstance(arg, SandboxDependsFunction):
- assert arg in self._depends
- f = self._depends[arg]
- if need_help_dependency and self._help_option not in f.dependencies:
- raise ConfigureError("Missing @depends for `%s`: '--help'" %
- f.name)
- return self._value_for(arg)
+ return self._value_for_depends(self._depends[arg],
+ need_help_dependency)
return arg
def _value_for(self, obj):
if isinstance(obj, SandboxDependsFunction):
assert obj in self._depends
return self._value_for_depends(self._depends[obj])
elif isinstance(obj, DependsFunction):
return self._value_for_depends(obj)
elif isinstance(obj, Option):
return self._value_for_option(obj)
assert False
@memoize
- def _value_for_depends(self, obj):
+ def _value_for_depends(self, obj, need_help_dependency=False):
assert not inspect.isgeneratorfunction(obj.func)
with_help = self._help_option in obj.dependencies
if with_help:
for arg in obj.dependencies:
if isinstance(arg, DependsFunction):
if self._help_option not in arg.dependencies:
raise ConfigureError(
"`%s` depends on '--help' and `%s`. "
"`%s` must depend on '--help'"
% (obj.name, arg.name, arg.name))
- elif self._help:
+ elif self._help or need_help_dependency:
raise ConfigureError("Missing @depends for `%s`: '--help'" %
obj.name)
+ return self._value_for_depends_real(obj)
+ @memoize
+ def _value_for_depends_real(self, obj):
resolved_args = [self._value_for(d) for d in obj.dependencies]
return obj.func(*resolved_args)
@memoize
def _value_for_option(self, option):
implied = {}
for implied_option in self._implied_options[:]:
if implied_option.name not in (option.name, option.env):