Bug 1316956 - Add a when argument to check_prog. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 13 May 2017 07:12:56 +0900
changeset 358166 563f87448eff9e4db7c11f9bfbfddc4c746ca514
parent 358165 d1ed0a4e7d97f808c1caa1ebc5116b51d1986621
child 358167 9efa29ce0e3edc8eb84c906328e3d08236fee6da
push id31818
push userarchaeopteryx@coole-files.de
push dateSun, 14 May 2017 16:01:21 +0000
treeherdermozilla-central@3a801856dea9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1316956
milestone55.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 1316956 - Add a when argument to check_prog. r=chmanchester
build/moz.configure/checks.configure
build/moz.configure/util.configure
--- a/build/moz.configure/checks.configure
+++ b/build/moz.configure/checks.configure
@@ -89,17 +89,17 @@ 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')
 def check_prog(var, progs, what=None, input=None, allow_missing=False,
-               paths=None):
+               paths=None, when=None):
     if input is not None:
         # Wrap input with type checking and normalization.
         @depends(input)
         def input(value):
             if not value:
                 return
             if isinstance(value, str):
                 return (value,)
@@ -112,17 +112,17 @@ def check_prog(var, progs, what=None, in
                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.
     progs = dependable(progs)
     paths = dependable(paths)
 
-    @depends_if(input, progs, paths)
+    @depends_if(input, progs, paths, when=when)
     @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)):
             configure_error('progs must resolve to a list or tuple!')
 
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -385,19 +385,24 @@ def delayed_getattr(func, key):
         return getattr(value, key, None)
 
     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 depends_if(*args, **kwargs):
+    if kwargs:
+        assert len(kwargs) == 1
+        when = kwargs['when']
+    else:
+        when = None
     def decorator(func):
-        @depends(*args)
+        @depends(*args, when=when)
         def wrapper(*args):
             if any(arg for arg in args):
                 return func(*args)
         return wrapper
     return decorator
 
 # Hacks related to old-configure
 # ==============================