Skip to content

Commit

Permalink
Bug 1313306 - Remove --help dependencies from @dependable and delayed…
Browse files Browse the repository at this point in the history
…_getattr. r=chmanchester

This sadly requires to replace a few @dependendable to pass the lint
check.

--HG--
extra : rebase_source : e0fd1c6f104076ea9f2c3474aadb7bebdf9a7fd8
  • Loading branch information
glandium committed Oct 27, 2016
1 parent c35a688 commit be15eb6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build/moz.configure/android-ndk.configure
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ js_option('--with-android-toolchain', nargs=1,
js_option('--with-android-gnu-compiler-version', nargs=1,
help='GNU compiler version to use')

min_android_version = dependable('9')
min_android_version = dependable(lambda: '9')

js_option('--with-android-version',
nargs=1,
Expand Down
4 changes: 2 additions & 2 deletions build/moz.configure/init.configure
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,6 @@ def js_option(*args, **kwargs):
# actual implementation is located in b2g/moz.configure.
# Remove this function as soon as 'android_ndk_include'
# depends on 'target.'
@dependable
def gonkdir():
@depends('--help')
def gonkdir(_):
return None
4 changes: 2 additions & 2 deletions build/moz.configure/old.configure
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,10 @@ def post_old_configure(raw_config):
# them. We only do so for options that haven't been declared so far,
# which should be a proxy for the options that old-configure handles
# and that we don't know anything about.
@dependable
@depends('--help')
@imports('__sandbox__')
@imports(_from='mozbuild.configure.options', _import='Option')
def remaining_mozconfig_options():
def remaining_mozconfig_options(_):
helper = __sandbox__._helper
for arg in helper:
if helper._origins[arg] != 'mozconfig':
Expand Down
18 changes: 5 additions & 13 deletions build/moz.configure/util.configure
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ def dependable(obj):
if isinstance(obj, SandboxDependsFunction):
return obj
if isfunction(obj):
return depends('--help')(lambda _: obj())
return depends('--help')(lambda _: obj)
return depends(when=True)(obj)
return depends(when=True)(lambda: obj)


always = dependable(True)
Expand All @@ -356,23 +356,15 @@ never = dependable(False)
# return namespace(foo=value)
# set_config('FOO', delayed_getattr(option, 'foo')
@template
@imports('__sandbox__')
def delayed_getattr(func, key):
deps = __sandbox__._depends.get(func, ())
if deps:
deps = deps.sandboxed_dependencies

def result(value, _=None):
@depends(func)
def result(value):
# The @depends function we're being passed may have returned
# None, or an object that simply doesn't have the wanted key.
# In that case, just return None.
return getattr(value, key, None)

# Automatically add a dependency on --help when the given @depends
# function itself depends on --help.
if __sandbox__._help_option in deps:
return depends(func, '--help')(result)
return depends(func)(result)
return result


# Like @depends, but the decorated function is only called if one of the
Expand Down
4 changes: 2 additions & 2 deletions moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ include('build/moz.configure/warnings.configure',

include(include_project_configure)

@dependable
@depends('--help')
@imports(_from='mozbuild.backend', _import='backends')
def build_backends_choices():
def build_backends_choices(_):
return tuple(backends)


Expand Down

0 comments on commit be15eb6

Please sign in to comment.