Bug 1257823 - Remove set_config implementation for @depends functions draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 22 Mar 2016 18:55:20 +0900
changeset 343864 df663e31087d9a06c9bd823c40545e1bd8bad957
parent 343863 767341c1e29822fbfd63c7a54e3b38abd452e1ba
child 343865 091702560d2b2e55708a94f4cef1cbdccdaf9cb1
push id13691
push userbmo:mh+mozilla@glandium.org
push dateWed, 23 Mar 2016 10:00:34 +0000
bugs1257823
milestone48.0a1
Bug 1257823 - Remove set_config implementation for @depends functions
python/mozbuild/mozbuild/configure/__init__.py
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -35,18 +35,18 @@ class DummyFunction(object):
         raise RuntimeError('The `%s` function may not be called'
                            % self.__name__)
 
 
 class SandboxedGlobal(dict):
     '''Identifiable dict type for use as function global'''
 
 
-class DependsOutput(dict):
-    '''Dict holding the results yielded by a @depends function.'''
+class DependsOutput(object):
+    '''Class for objects holding the options implied by a @depends function.'''
     __slots__ = ('implied_options',)
 
     def __init__(self):
         super(DependsOutput, self).__init__()
         self.implied_options = []
 
     def imply_option(self, option, reason=None):
         if not isinstance(option, types.StringTypes):
@@ -285,22 +285,21 @@ class ConfigureSandbox(dict):
         references. The decorated function is called as soon as the decorator
         is called, and the arguments it receives are the OptionValue or
         function results corresponding to each of the arguments to @depends.
         As an exception, when a HelpFormatter is attached, only functions that
         have '--help' in their @depends argument list are called.
 
         The decorated function is altered to use a different global namespace
         for its execution. This different global namespace exposes a limited
-        set of functions from os.path, and three additional functions:
-        `imply_option`, `set_config` and `set_define`. The first allows to
-        inject additional options as if they had been passed on the command
-        line. The second declares new configuration items for consumption by
-        moz.build. The last declares new defines, stored in a DEFINES
-        configuration item.
+        set of functions from os.path, and two additional functions:
+        `imply_option` and `set_define`. The former allows to inject
+        additional options as if they had been passed on the command line.
+        The latter declares new defines, stored in a DEFINES configuration
+        item.
         '''
         if not args:
             raise ConfigureError('@depends needs at least one argument')
 
         with_help = False
         resolved_args = []
         for arg in args:
             if isinstance(arg, types.StringTypes):
@@ -330,17 +329,16 @@ class ConfigureSandbox(dict):
         def decorator(func):
             if inspect.isgeneratorfunction(func):
                 raise ConfigureError(
                     'Cannot decorate generator functions with @depends')
             func, glob = self._prepare_function(func)
             result = DependsOutput()
             glob.update(
                 imply_option=result.imply_option,
-                set_config=result.__setitem__,
                 set_define=self._set_define,
             )
             dummy = wraps(func)(DummyFunction())
             self._depends[dummy] = func
             func.with_help = with_help
             if with_help:
                 for arg in args:
                     if (isinstance(arg, DummyFunction) and
@@ -371,24 +369,16 @@ class ConfigureSandbox(dict):
                             or name))
                     if len(deps) != 1:
                         raise ConfigureError(
                             "Cannot infer what implied '%s'" % option)
                     reason = deps[0]
 
                 self._implied_options[option] = func, reason
 
-            if not self._help:
-                for k, v in result.iteritems():
-                    if k in self._config:
-                        raise ConfigureError(
-                            "Cannot add '%s' to configuration: Key already "
-                            "exists" % k)
-                    self._config[k] = v
-
             return dummy
 
         return decorator
 
     def include_impl(self, what):
         '''Implementation of include().
         Allows to include external files for execution in the sandbox.
         It is possible to use a @depends function as argument, in which case