Bug 1316956 - Add a when argument to check_prog. r?chmanchester
--- 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
# ==============================