Bug 1287924 - Add a template for conditionally including moz.configure files. draft
authorChris Manchester <cmanchester@mozilla.com>
Mon, 25 Jul 2016 16:24:40 -0700
changeset 392660 8a559de06e80286dfcce64f639812f4a7e33532c
parent 392659 65d4dc4d8cda1d101620b695c8b834181f903e14
child 526375 8916f5f7df4d1d86c0c37428ece2217b461408ed
push id24078
push usercmanchester@mozilla.com
push dateMon, 25 Jul 2016 23:35:28 +0000
bugs1287924
milestone50.0a1
Bug 1287924 - Add a template for conditionally including moz.configure files. MozReview-Commit-ID: FyT7jLmTxvP
build/moz.configure/util.configure
moz.configure
--- 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='+',