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 308979 9a9a569a4c4753d9b8b9e86d2d6c443ec5f3f861
parent 308978 a221be4979b129cba69c417567ee0537c3b35924
child 308980 85f934cbd5fda46812d1fc49b7b6de12e35bc23b
push id30556
push userkwierso@gmail.com
push dateFri, 12 Aug 2016 16:45:27 +0000
treeherdermozilla-central@c4ad5f94a5bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1293579
milestone51.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 1293579 - Use the new `dependable` function in a few places. r=chmanchester
build/moz.configure/android-ndk.configure
build/moz.configure/checks.configure
build/moz.configure/compile-checks.configure
build/moz.configure/init.configure
build/moz.configure/old.configure
build/moz.configure/pkg.configure
build/moz.configure/toolchain.configure
moz.configure
--- 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')
 
-@depends('--help')
-def min_android_version(_):
-    return '9'
+min_android_version = dependable('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/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.
 @template
 @imports(_from='mozbuild.shellutil', _import='quote')
-@imports(_from='mozbuild.configure', _import='DependsFunction')
 def check_prog(var, progs, what=None, input=None, allow_missing=False,
                paths=None):
     if input:
         # Wrap input with type checking and normalization.
         @depends(input)
         def input(value):
             if not value:
                 return
@@ -110,20 +109,18 @@ def check_prog(var, progs, what=None, in
                             'single element, or a string')
     else:
         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.
 @template
 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[:]
     else:
         includes = []
     includes.append(header)
 
     @depends_when(try_compile(includes=includes, language=language, flags=flags,
@@ -99,18 +99,17 @@ def warnings_cxxflags(cxx_compiler):
 #   for add_gcc_warning().
 @template
 def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
     if compiler:
         compilers = (compiler,)
     else:
         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),
         }[c]
 
--- 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
 # ==============================
 
-@depends('--help')
-def old_configure_assignments(help):
+@dependable
+def old_configure_assignments():
     return []
 
-@depends('--help')
-def extra_old_configure_args(help):
+@dependable
+def extra_old_configure_args():
     return []
 
 @template
-@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:
             return
         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.
 @template
 def early_options():
-    @depends('--help')
+    @dependable
     @imports('__sandbox__')
-    def early_options(help):
+    def early_options():
         return set(
             option.env
             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.'
-@depends('--help')
-def gonkdir(_):
+@dependable
+def gonkdir():
     return None
 
 include(include_project_configure)
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -140,18 +140,18 @@ def prepare_configure(old_configure, moz
     return cmd
 
 
 @template
 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,
                    *options)
 
 
 @old_configure_options(
     '--cache-file',
@@ -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.
-@depends('--help')
+@dependable
 @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/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.
 @template
-@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,
                       allow_missing=False):
     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)
 
-@depends('--help')
-def extra_toolchain_flags(_):
+@dependable
+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
              when='--enable-compile-environment')
 include_when('build/moz.configure/memory.configure',
              when='--enable-compile-environment')
 include_when('build/moz.configure/headers.configure',
              when='--enable-compile-environment')
 include_when('build/moz.configure/warnings.configure',
              when='--enable-compile-environment')
 
-@depends('--help')
+@dependable
 @imports(_from='mozbuild.backend', _import='backends')
-def build_backends_choices(help):
+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)