Bug 1313306 - Remove --help dependencies from @dependable and delayed_getattr. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 27 Oct 2016 15:00:51 +0900
changeset 320415 8158226d06a0ca0f69c60a87adfaef1a6151f285
parent 320414 0ac9e88ff47be0989d6a2eb609583c78acac2ade
child 320416 fd21663f4363ff852d9b9063a0a4742816cc14f9
push id30901
push userkwierso@gmail.com
push dateThu, 03 Nov 2016 00:16:45 +0000
treeherdermozilla-central@ac55a6776435 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1313306
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1313306 - Remove --help dependencies from @dependable and delayed_getattr. r=chmanchester This sadly requires to replace a few @dependendable to pass the lint check.
build/moz.configure/android-ndk.configure
build/moz.configure/init.configure
build/moz.configure/old.configure
build/moz.configure/util.configure
moz.configure
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -9,17 +9,17 @@ js_option('--with-android-ndk', nargs=1,
           help='location where the Android NDK can be found')
 
 js_option('--with-android-toolchain', nargs=1,
           help='location of the Android toolchain')
 
 js_option('--with-android-gnu-compiler-version', nargs=1,
           help='GNU compiler version to use')
 
-min_android_version = dependable('9')
+min_android_version = dependable(lambda: '9')
 
 js_option('--with-android-version',
           nargs=1,
           help='android platform version',
           default=min_android_version)
 
 @depends('--with-android-version', min_android_version)
 @imports(_from='__builtin__', _import='ValueError')
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -808,11 +808,11 @@ def js_option(*args, **kwargs):
     add_old_configure_arg(js_option)
 
 
 # Bug 1278542: This function is a workaround to resolve
 # |android_ndk_include|'s dependency on 'gonkdir.' The
 # actual implementation is located in b2g/moz.configure.
 # Remove this function as soon as 'android_ndk_include'
 # depends on 'target.'
-@dependable
-def gonkdir():
+@depends('--help')
+def gonkdir(_):
     return None
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -404,20 +404,20 @@ def post_old_configure(raw_config):
 
 
 # Assuming no other option is declared after this function, handle the
 # env options that were injected by mozconfig_options by creating dummy
 # Option instances and having the sandbox's CommandLineHelper handle
 # them. We only do so for options that haven't been declared so far,
 # which should be a proxy for the options that old-configure handles
 # and that we don't know anything about.
-@dependable
+@depends('--help')
 @imports('__sandbox__')
 @imports(_from='mozbuild.configure.options', _import='Option')
-def remaining_mozconfig_options():
+def remaining_mozconfig_options(_):
     helper = __sandbox__._helper
     for arg in helper:
         if helper._origins[arg] != 'mozconfig':
             continue
         name = arg.split('=', 1)[0]
         if name.isupper() and name not in __sandbox__._options:
             option = Option(env=name, nargs='*', help=name)
             helper.handle(option)
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -333,51 +333,43 @@ def namespace(**kwargs):
 # or, for convenience, a @depends function.
 @template
 @imports(_from='inspect', _import='isfunction')
 @imports(_from='mozbuild.configure', _import='SandboxDependsFunction')
 def dependable(obj):
     if isinstance(obj, SandboxDependsFunction):
         return obj
     if isfunction(obj):
-        return depends('--help')(lambda _: obj())
-    return depends('--help')(lambda _: obj)
+        return depends(when=True)(obj)
+    return depends(when=True)(lambda: obj)
 
 
 always = dependable(True)
 never = dependable(False)
 
 
 # Some @depends function return namespaces, and one could want to use one
 # specific attribute from such a namespace as a "value" given to functions
 # such as `set_config`. But those functions do not take immediate values.
 # The `delayed_getattr` function allows access to attributes from the result
 # of a @depends function in a non-immediate manner.
 #   @depends('--option')
 #   def option(value)
 #       return namespace(foo=value)
 #   set_config('FOO', delayed_getattr(option, 'foo')
 @template
-@imports('__sandbox__')
 def delayed_getattr(func, key):
-    deps = __sandbox__._depends.get(func, ())
-    if deps:
-        deps = deps.sandboxed_dependencies
-
-    def result(value, _=None):
+    @depends(func)
+    def result(value):
         # The @depends function we're being passed may have returned
         # None, or an object that simply doesn't have the wanted key.
         # In that case, just return None.
         return getattr(value, key, None)
 
-    # Automatically add a dependency on --help when the given @depends
-    # function itself depends on --help.
-    if __sandbox__._help_option in deps:
-        return depends(func, '--help')(result)
-    return depends(func)(result)
+    return result
 
 
 # Like @depends, but the decorated function is only called if one of the
 # arguments it would be called with has a positive value (bool(value) is True)
 @template
 def depends_if(*args):
     def decorator(func):
         @depends(*args)
--- a/moz.configure
+++ b/moz.configure
@@ -114,19 +114,19 @@ include('build/moz.configure/memory.conf
         when='--enable-compile-environment')
 include('build/moz.configure/headers.configure',
         when='--enable-compile-environment')
 include('build/moz.configure/warnings.configure',
         when='--enable-compile-environment')
 
 include(include_project_configure)
 
-@dependable
+@depends('--help')
 @imports(_from='mozbuild.backend', _import='backends')
-def build_backends_choices():
+def build_backends_choices(_):
     return tuple(backends)
 
 
 @deprecated_option('--enable-build-backend', nargs='+',
                    choices=build_backends_choices)
 def build_backend(backends):
     if backends:
         return tuple('+%s' % b for b in backends)