Bug 1287924 - Add a template for conditionally including moz.configure files. r=glandium
authorChris Manchester <cmanchester@mozilla.com>
Tue, 26 Jul 2016 15:27:19 -0700
changeset 331872 83db605b772e7d7fe1e27d0bb3cea5e117ceafad
parent 331871 550fc29355f102a40f897b958fee7c2776a99fb3
child 331873 7a7cab1878fce38a4909b3e8a19ffe62d097b821
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1287924
milestone50.0a1
Bug 1287924 - Add a template for conditionally including moz.configure files. r=glandium MozReview-Commit-ID: FyT7jLmTxvP
build/moz.configure/toolchain.configure
build/moz.configure/util.configure
moz.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -60,22 +60,20 @@ def extra_toolchain_flags(_):
     # This value will be overriden for android builds, where
     # extra flags are required to do basic checks.
     return []
 
 # Android NDK
 # ==============================================================
 
 @depends('--disable-compile-environment', build_project, gonkdir, '--help')
-def android_ndk_include(compile_env, build_project, gonkdir, _):
-    if compile_env and (gonkdir or build_project in ('mobile/android', 'js')):
-        return 'android-ndk.configure'
+def compiling_android(compile_env, build_project, gonkdir, _):
+    return compile_env and (gonkdir or build_project in ('mobile/android', 'js'))
 
-include(android_ndk_include)
-
+include_when('android-ndk.configure', when=compiling_android)
 
 # MacOS deployment target version
 # ==============================================================
 # This needs to happen before any compilation test is done.
 
 option('--enable-macos-target', env='MACOSX_DEPLOYMENT_TARGET', nargs=1,
        default='10.7', help='Set the minimum MacOS version needed at runtime')
 
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -209,8 +209,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',
+             when='--enable-compile-environment')
+include_when('build/moz.configure/memory.configure',
+             when='--enable-compile-environment')
+include_when('build/moz.configure/headers.configure',
+             when='--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='+',