Skip to content

Commit

Permalink
Bug 1287924 - Add a template for conditionally including moz.configur…
Browse files Browse the repository at this point in the history
…e files. r=glandium

MozReview-Commit-ID: FyT7jLmTxvP
  • Loading branch information
chmanchester committed Jul 26, 2016
1 parent 84564f1 commit b7387e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
8 changes: 3 additions & 5 deletions build/moz.configure/toolchain.configure
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ def extra_toolchain_flags(_):
# ==============================================================

@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'

include(android_ndk_include)
def compiling_android(compile_env, build_project, gonkdir, _):
return compile_env and (gonkdir or build_project in ('mobile/android', 'js'))

include_when('android-ndk.configure', when=compiling_android)

# MacOS deployment target version
# ==============================================================
Expand Down
10 changes: 10 additions & 0 deletions build/moz.configure/util.configure
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,13 @@ def depends_when(*args, **kwargs):
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)
26 changes: 6 additions & 20 deletions moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,12 @@ js_option('--enable-debug',
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')
Expand Down

0 comments on commit b7387e8

Please sign in to comment.