Bug 1287924 - Add a template for conditionally including moz.configure files.
MozReview-Commit-ID: FyT7jLmTxvP
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -207,8 +207,18 @@ def depends_when(*args, **kwargs):
when = kwargs['when']
def decorator(fn):
@depends(when, *args)
def wrapper(val, *args):
if val:
return fn(*args)
return wrapper
return decorator
+
+# Includes a file when the given condition evaluates to a truthy value.
+@template
+def include_when(filename, when):
+ # Assume, for now, our condition already depends on --help.
+ @depends(when, '--help')
+ def conditional_include(value, _):
+ if value:
+ return filename
+ include(conditional_include)
--- a/moz.configure
+++ b/moz.configure
@@ -88,36 +88,22 @@ set_define('GTEST_HAS_CLONE',
js_option('--enable-debug',
nargs='?',
help='Enable building with developer debug info '
'(using the given compiler flags).')
add_old_configure_assignment('MOZ_DEBUG',
depends('--enable-debug')(lambda v: bool(v)))
-@depends('--disable-compile-environment', '--help')
-def toolchain_include(compile_env, help):
- if compile_env:
- return 'build/moz.configure/toolchain.configure'
-
-include(toolchain_include)
-
-@depends('--disable-compile-environment', '--help')
-def memory_include(compile_env, help):
- if compile_env:
- return 'build/moz.configure/memory.configure'
-
-include(memory_include)
-
-@depends('--disable-compile-environment', '--help')
-def headers_check_include(compile_env, help):
- if compile_env:
- return 'build/moz.configure/headers.configure'
-
-include(headers_check_include)
+include_when('build/moz.configure/toolchain.configure',
+ '--enable-compile-environment')
+include_when('build/moz.configure/memory.configure',
+ '--enable-compile-environment')
+include_when('build/moz.configure/headers.configure',
+ '--enable-compile-environment')
@depends('--help')
@imports(_from='mozbuild.backend', _import='backends')
def build_backends_choices(help):
return tuple(backends)
@deprecated_option('--enable-build-backend', nargs='+',