Bug 1293579 - Use the new `dependable` function in a few places. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 09 Aug 2016 15:55:10 +0900
changeset 352482 9a9a569a4c4753d9b8b9e86d2d6c443ec5f3f861
parent 352481 a221be4979b129cba69c417567ee0537c3b35924
child 352483 85f934cbd5fda46812d1fc49b7b6de12e35bc23b
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1293579 - Use the new `dependable` function in a few places. r=chmanchester
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -9,19 +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')
-def min_android_version(_):
-    return '9'
+min_android_version = dependable('9')
           help='android platform version',
 @depends('--with-android-version', min_android_version)
 @imports(_from='__builtin__', _import='ValueError')
--- a/build/moz.configure/checks.configure
+++ b/build/moz.configure/checks.configure
@@ -88,17 +88,16 @@ def checking(what, callback=None):
 # The simplest form is:
 #   check_prog('PROG', ('a', 'b'))
 # This will look for 'a' or 'b' in $PATH, and set_config PROG to the one
 # it can find. If PROG is already set from the environment or command line,
 # use that value instead.
 @imports(_from='mozbuild.shellutil', _import='quote')
-@imports(_from='mozbuild.configure', _import='DependsFunction')
 def check_prog(var, progs, what=None, input=None, allow_missing=False,
     if input:
         # Wrap input with type checking and normalization.
         def input(value):
             if not value:
@@ -110,20 +109,18 @@ def check_prog(var, progs, what=None, in
                             'single element, or a string')
         option(env=var, nargs=1,
                help='Path to %s' % (what or 'the %s program' % var.lower()))
         input = var
     what = what or var.lower()
     # Trick to make a @depends function out of an immediate value.
-    if not isinstance(progs, DependsFunction):
-        progs = depends('--help')(lambda h: progs)
-    if not isinstance(paths, DependsFunction):
-        paths = depends('--help')(lambda h: paths)
+    progs = dependable(progs)
+    paths = dependable(paths)
     @depends_if(input, progs, paths)
     @checking('for %s' % what, lambda x: quote(x) if x else 'not found')
     def check(value, progs, paths):
         if progs is None:
             progs = ()
         if not isinstance(progs, (tuple, list)):
--- a/build/moz.configure/compile-checks.configure
+++ b/build/moz.configure/compile-checks.configure
@@ -39,17 +39,17 @@ def try_compile(includes=None, body='', 
 #   used.
 # - `flags` are the flags to be passed to the compiler, in addition to `-c`.
 # - `includes` are additional includes, as file names, to appear before the
 #   header checked for.
 # - `when` is a depends function that if present will make performing the check
 #   conditional on the value of that function.
 def check_header(header, language='C++', flags=None, includes=None, when=None):
-    when = when or depends('--help')(lambda _: True)
+    when = when or always
     if includes:
         includes = includes[:]
         includes = []
     @depends_when(try_compile(includes=includes, language=language, flags=flags,
@@ -99,18 +99,17 @@ def warnings_cxxflags(cxx_compiler):
 #   for add_gcc_warning().
 def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
     if compiler:
         compilers = (compiler,)
         compilers = (c_compiler, cxx_compiler)
-    if not when:
-        when = depends('--help')(lambda _: True)
+    when = when or always
     for c in compilers:
         assert c in (c_compiler, cxx_compiler)
         lang, warnings_flags = {
             c_compiler: ('C', warnings_cflags),
             cxx_compiler: ('C++', warnings_cxxflags),
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -120,31 +120,28 @@ def mozconfig(current_project, mozconfig
     return mozconfig
 set_config('MOZCONFIG', depends(mozconfig)(lambda m: m['path']))
 # Hacks related to old-configure
 # ==============================
-def old_configure_assignments(help):
+def old_configure_assignments():
     return []
-def extra_old_configure_args(help):
+def extra_old_configure_args():
     return []
-@imports(_from='mozbuild.configure', _import='DependsFunction')
 def add_old_configure_assignment(var, value):
-    if not isinstance(var, DependsFunction):
-        var = depends('--help')(lambda x: var)
-    if not isinstance(value, DependsFunction):
-        value = depends('--help')(lambda x: value)
+    var = dependable(var)
+    value = dependable(value)
     @depends(old_configure_assignments, var, value)
     @imports(_from='mozbuild.shellutil', _import='quote')
     def add_assignment(assignments, var, value):
         if var is None or value is None:
         if value is True:
             assignments.append('%s=1' % var)
@@ -243,19 +240,19 @@ set_config('PYTHON', virtualenv_python)
 add_old_configure_assignment('PYTHON', virtualenv_python)
 # Inject mozconfig options
 # ==============================================================
 # All options defined above this point can't be injected in mozconfig_options
 # below, so collect them.
 def early_options():
-    @depends('--help')
+    @dependable
-    def early_options(help):
+    def early_options():
         return set(
             for option in __sandbox__._options.itervalues()
             if option.env
     return early_options
 early_options = early_options()
@@ -799,13 +796,13 @@ include('pkg.configure')
 # requiring this file in unit tests.
 add_old_configure_assignment('PKG_CONFIG', pkg_config)
 # 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.'
-def gonkdir(_):
+def gonkdir():
     return None
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -140,18 +140,18 @@ def prepare_configure(old_configure, moz
     return cmd
 def old_configure_options(*options):
     for opt in options:
         option(opt, nargs='*', help='Help missing for old configure options')
-    @depends('--help')
-    def all_options(help):
+    @dependable
+    def all_options():
         return list(options)
     return depends(prepare_configure, extra_old_configure_args, all_options,
@@ -433,20 +433,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.
 @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':
         name = arg.split('=', 1)[0]
         if name.isupper() and name not in __sandbox__._options:
             option = Option(env=name, nargs='*', help=name)
--- a/build/moz.configure/pkg.configure
+++ b/build/moz.configure/pkg.configure
@@ -20,24 +20,21 @@ def pkg_config_version(pkg_config):
 #   resolve to such a string or list of strings.
 # - `condition` a depends function that will determine whether to perform
 #   any checks (default is to always perform checks).
 # - `allow_missing` If set, failure to fulfill the package description
 #   will not result in an error or logged message, and any error message
 #   will be returned to the caller.
 #   Returns `True` when the package description is fulfilled.
-@imports(_from='mozbuild.configure', _import='DependsFunction')
-def pkg_check_modules(var, package_desc,
-                      condition=depends('--help')(lambda _: True),
+def pkg_check_modules(var, package_desc, condition=always,
     if isinstance(package_desc, (tuple, list)):
         package_desc = ' '.join(package_desc)
-    if not isinstance(package_desc, DependsFunction):
-        package_desc = depends('--help')(lambda _: package_desc)
+    package_desc = dependable(package_desc)
     @depends_when(pkg_config, pkg_config_version, when=condition)
     def check_pkg_config(pkg_config, version):
         min_version = '0.9.0'
         if pkg_config is None:
             die("*** The pkg-config script could not be found. Make sure it is\n"
                 "*** in your path, or set the PKG_CONFIG environment variable\n"
                 "*** to the full path to pkg-config.")
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -57,18 +57,18 @@ set_config('YASM_ASFLAGS', yasm_asflags)
 def have_yasm(value):
     if value:
         return True
 set_config('HAVE_YASM', have_yasm)
 # Until the YASM variable is not necessary in old-configure.
 add_old_configure_assignment('YASM', have_yasm)
-def extra_toolchain_flags(_):
+def extra_toolchain_flags():
     # This value will be overriden for android builds, where
     # extra flags are required to do basic checks.
     return []
 # Android NDK
 # ==============================================================
 @depends('--disable-compile-environment', build_project, gonkdir, '--help')
--- a/moz.configure
+++ b/moz.configure
@@ -97,19 +97,19 @@ include_when('build/moz.configure/toolch
 @imports(_from='mozbuild.backend', _import='backends')
-def build_backends_choices(help):
+def build_backends_choices():
     return tuple(backends)
 @deprecated_option('--enable-build-backend', nargs='+',
 def build_backend(backends):
     if backends:
         return tuple('+%s' % b for b in backends)