Bug 1296530 - Move the somehow redundant check for --help dependency from _resolve to _value_for_depends. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 11 Oct 2016 14:20:18 +0900
changeset 425033 e8c8ddfb166ecf0f080be3896d7975e210a2cb27
parent 425032 c6be6a83b7440ccffe020d57165b1c6b1483c037
child 425034 e4e0ec46b30ed1a8fe8c7812de6551bd4d22bfc7
push id32321
push userbmo:mh+mozilla@glandium.org
push dateFri, 14 Oct 2016 02:53:47 +0000
reviewerschmanchester
bugs1296530
milestone52.0a1
Bug 1296530 - Move the somehow redundant check for --help dependency from _resolve to _value_for_depends. r?chmanchester
python/mozbuild/mozbuild/configure/__init__.py
--- 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):