Bug 1259620 - Add an optional formatting callback to @checking. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 24 Mar 2016 17:43:31 +0900
changeset 328323 67e1d5126c9f68e424353a4412bfc31486d723ad
parent 328322 5eecbb62c31e3f6974cdaf8d71d153aab1f7fe57
child 328324 a7d69f146a52ccfa013aa3aed251ae8086ef84d8
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [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 1259620 - Add an optional formatting callback to @checking. r=gps
--- a/build/moz.configure/checks.configure
+++ b/build/moz.configure/checks.configure
@@ -16,26 +16,30 @@
 #       ret = foo
 #       sys.stdout.write(ret + '\n')
 #       return ret
 # This can be combined with e.g. @depends:
 #   @depends(some_option)
 #   @checking('for something')
 #   def check(value):
 #       ...
+# An optional callback can be given, that will be used to format the returned
+# value when displaying it.
-def checking(what):
+def checking(what, callback=None):
     def decorator(func):
         def wrapped(*args, **kwargs):
             import sys
             print('checking', what, end='... ')
             ret = func(*args, **kwargs)
-            if ret is True:
+            if callback:
+                print(callback(ret))
+            elif ret is True:
             elif ret is False:
             return ret
         return wrapped
@@ -46,40 +50,37 @@ def checking(what):
 #   check('PROG', ('a', 'b'))
 # 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.
 def check_prog(var, progs, allow_missing=False):
     option(env=var, nargs=1, help='Path to the %s program' % var.lower())
-    not_found = 'not found'
     if not (isinstance(progs, tuple) or isinstance(progs, list)):
         configure_error('progs should be a list or tuple!')
     progs = list(progs)
-    @checking('for %s' % var.lower())
+    @checking('for %s' % var.lower(), lambda x: x or 'not found')
     def check(value):
         if value:
             progs[:] = value
         for prog in progs:
             result = find_program(prog)
             if result:
                 return result
-        return not_found
     @depends(check, var)
     def postcheck(value, raw_value):
-        if value is not_found and (not allow_missing or raw_value):
+        if value is None and (not allow_missing or raw_value):
             from mozbuild.shellutil import quote
             error('Cannot find %s (tried: %s)'
                   % (var.lower(), ', '.join(quote(p) for p in progs)))
-        return None if value is not_found else value
-    @depends(postcheck)
+    @depends(check)
     def normalized_for_config(value):
         return ':' if value is None else value
     set_config(var, normalized_for_config)
-    return postcheck
+    return check