Bug 1335666 - Remove @depends_when. r=chmanchester

In bug 1296530, we made @depends take a when argument, it can now replace
all uses of @depends_when.

--HG--
extra : rebase_source : d090723fcbf3a56e06bd9c2defc3301cac04d8b0
This commit is contained in:
Mike Hommey 2017-02-01 16:25:29 +09:00
parent 881244bdbf
commit 9de779f50a
5 changed files with 13 additions and 33 deletions

View File

@ -43,7 +43,7 @@ def compiler_class(compiler):
def checking_fn(fn): def checking_fn(fn):
return fn return fn
@depends_when(self, dependable(flags), extra_toolchain_flags, when=when) @depends(self, dependable(flags), extra_toolchain_flags, when=when)
@checking_fn @checking_fn
def func(compiler, flags, extra_flags): def func(compiler, flags, extra_flags):
flags = flags or [] flags = flags or []

View File

@ -74,11 +74,11 @@ js_option('--with-linux-headers',
passed_linux_header_flags = depends_if('--with-linux-headers')(lambda v: ['-I%s' % v[0]]) passed_linux_header_flags = depends_if('--with-linux-headers')(lambda v: ['-I%s' % v[0]])
@depends_when(try_compile(includes=['asm/unistd.h'], @depends(try_compile(includes=['asm/unistd.h'],
body='return sizeof(__NR_perf_event_open);', body='return sizeof(__NR_perf_event_open);',
flags=passed_linux_header_flags, flags=passed_linux_header_flags,
check_msg='for perf_event_open system call'), check_msg='for perf_event_open system call'),
when=have_perf_event_h) when=have_perf_event_h)
def have_perf_event_open(have_perf_event_open): def have_perf_event_open(have_perf_event_open):
if have_perf_event_open: if have_perf_event_open:
return True return True

View File

@ -40,8 +40,8 @@ def pkg_check_modules(var, package_desc, when=always,
def when_and_compile_environment(when, compile_environment): def when_and_compile_environment(when, compile_environment):
return when and compile_environment return when and compile_environment
@depends_when(pkg_config, pkg_config_version, @depends(pkg_config, pkg_config_version,
when=when_and_compile_environment) when=when_and_compile_environment)
def check_pkg_config(pkg_config, version): def check_pkg_config(pkg_config, version):
min_version = '0.9.0' min_version = '0.9.0'
if pkg_config is None: if pkg_config is None:
@ -52,7 +52,7 @@ def pkg_check_modules(var, package_desc, when=always,
die("*** Your version of pkg-config is too old. You need version %s or newer.", die("*** Your version of pkg-config is too old. You need version %s or newer.",
min_version) min_version)
@depends_when(pkg_config, package_desc, when=when_and_compile_environment) @depends(pkg_config, package_desc, when=when_and_compile_environment)
@imports('subprocess') @imports('subprocess')
@imports('sys') @imports('sys')
@imports(_from='mozbuild.configure.util', _import='LineIO') @imports(_from='mozbuild.configure.util', _import='LineIO')
@ -74,20 +74,20 @@ def pkg_check_modules(var, package_desc, when=always,
if not allow_missing: if not allow_missing:
sys.exit(1) sys.exit(1)
@depends_when(pkg_config, package_desc, when=package) @depends(pkg_config, package_desc, when=package)
@checking('%s_CFLAGS' % var, callback=lambda t: ' '.join(t)) @checking('%s_CFLAGS' % var, callback=lambda t: ' '.join(t))
def pkg_cflags(pkg_config, package_desc): def pkg_cflags(pkg_config, package_desc):
flags = check_cmd_output(pkg_config, '--cflags', package_desc) flags = check_cmd_output(pkg_config, '--cflags', package_desc)
return tuple(flags.split()) return tuple(flags.split())
@depends_when(pkg_config, package_desc, when=package) @depends(pkg_config, package_desc, when=package)
@checking('%s_LIBS' % var, callback=lambda t: ' '.join(t)) @checking('%s_LIBS' % var, callback=lambda t: ' '.join(t))
def pkg_libs(pkg_config, package_desc): def pkg_libs(pkg_config, package_desc):
libs = check_cmd_output(pkg_config, '--libs', package_desc) libs = check_cmd_output(pkg_config, '--libs', package_desc)
# Remove evil flags like -Wl,--export-dynamic # Remove evil flags like -Wl,--export-dynamic
return tuple(libs.replace('-Wl,--export-dynamic', '').split()) return tuple(libs.replace('-Wl,--export-dynamic', '').split())
@depends_when(pkg_cflags, pkg_libs, when=package) @depends(pkg_cflags, pkg_libs, when=package)
def pkg_info(cflags, libs): def pkg_info(cflags, libs):
return namespace(cflags=cflags, libs=libs) return namespace(cflags=cflags, libs=libs)

View File

@ -399,26 +399,6 @@ def depends_if(*args):
return wrapper return wrapper
return decorator return decorator
# Like @depends_if, but a distinguished value passed as a keyword argument
# "when" is truth tested instead of every argument. This value is not passed
# to the function if it is called.
@template
def depends_when(*args, **kwargs):
if not len(kwargs) == 1 and kwargs.get('when'):
die('depends_when requires a single keyword argument, "when"')
when = kwargs['when']
if not when:
return depends(*args)
def decorator(fn):
@depends(when, *args)
def wrapper(val, *args):
if val:
return fn(*args)
return wrapper
return decorator
# Hacks related to old-configure # Hacks related to old-configure
# ============================== # ==============================

View File

@ -26,7 +26,7 @@ set_config('MOZ_SYSTEM_FFI', depends_if(system_ffi)(lambda _: True))
add_old_configure_assignment('MOZ_SYSTEM_FFI', depends_if(system_ffi)(lambda _: True)) add_old_configure_assignment('MOZ_SYSTEM_FFI', depends_if(system_ffi)(lambda _: True))
# Target selection, based on ffi/configure.ac. # Target selection, based on ffi/configure.ac.
@depends_when(target, when=building_ffi) @depends(target, when=building_ffi)
def ffi_target(target): def ffi_target(target):
if target.cpu not in ('x86', 'x86_64', 'arm', 'aarch64'): if target.cpu not in ('x86', 'x86_64', 'arm', 'aarch64'):
die('Building libffi from the tree is not supported on this platform. ' die('Building libffi from the tree is not supported on this platform. '