Bug 1316956 - Add a when argument to check_prog. r=chmanchester, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 13 May 2017 07:12:56 +0900
changeset 357456 8ba410e8ca332d078126b2b358068b0b05768a42
parent 357455 e64be065932348fbb737065cbc3c51da107c9285
child 357457 7c20be9a414481c0986b3ab109c9ebc8efb0c1de
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester, IanN
Bug 1316956 - Add a when argument to check_prog. r=chmanchester, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH
--- 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.
 @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.
         def input(value):
             if not value:
             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)
-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
 # ==============================