mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1498450 - Avoid the footgun from @depends-function comparison r=froydnj
While we do have some uses of @depends-function comparison in some templaces, related to host/target, we ought to be using `is` comparisons rather than `==` anyways, so we switch those, and prevent other kinds of comparisons being used at all. This unveils the one noted in https://phabricator.services.mozilla.com/D7713?id=21357#inline-30414 (and surprisingly only that one), that we remove entirely since it was doing nothing in practice. Bug 1492305 will have to add it back in a proper form. Differential Revision: https://phabricator.services.mozilla.com/D8501 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c38ab87983
commit
148c9de331
@ -112,8 +112,8 @@ def check_and_add_flags(flag, flags_collection, test_flags,
|
||||
flags = [flag]
|
||||
|
||||
for c in compilers:
|
||||
assert c in (c_compiler, cxx_compiler,
|
||||
host_c_compiler, host_cxx_compiler)
|
||||
assert c in {c_compiler, cxx_compiler,
|
||||
host_c_compiler, host_cxx_compiler}
|
||||
lang, list_of_flags = {
|
||||
c_compiler: ('C', flags_collection.cflags),
|
||||
cxx_compiler: ('C++', flags_collection.cxxflags),
|
||||
|
@ -152,7 +152,7 @@ def rust_triple_alias(host_or_target):
|
||||
`host_or_target` is either `host` or `target` (the @depends functions
|
||||
from init.configure).
|
||||
"""
|
||||
assert host_or_target in (host, target)
|
||||
assert host_or_target in {host, target}
|
||||
|
||||
@depends(rustc, host_or_target, c_compiler, rust_supported_targets,
|
||||
when=rust_compiler)
|
||||
|
@ -693,7 +693,7 @@ def default_c_compilers(host_or_target, other_c_compiler=None):
|
||||
from init.configure.
|
||||
`other_c_compiler` is the `target` C compiler when `host_or_target` is `host`.
|
||||
'''
|
||||
assert host_or_target in (host, target)
|
||||
assert host_or_target in {host, target}
|
||||
|
||||
other_c_compiler = () if other_c_compiler is None else (other_c_compiler,)
|
||||
|
||||
@ -838,11 +838,11 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
|
||||
`other_c_compiler` is the result of the `compiler` template for the
|
||||
language 'C' for `target`.
|
||||
'''
|
||||
assert host_or_target in (host, target)
|
||||
assert host_or_target in {host, target}
|
||||
assert language in ('C', 'C++')
|
||||
assert language == 'C' or c_compiler is not None
|
||||
assert host_or_target == target or other_compiler is not None
|
||||
assert language == 'C' or host_or_target == target or \
|
||||
assert host_or_target is target or other_compiler is not None
|
||||
assert language == 'C' or host_or_target is target or \
|
||||
other_c_compiler is not None
|
||||
|
||||
host_or_target_str = {
|
||||
@ -1050,7 +1050,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
|
||||
# need to check this works for preprocessing, because we already relied
|
||||
# on $CC -E/$CXX -E doing preprocessing work to validate the compiler
|
||||
# in the first place.
|
||||
if host_or_target == target:
|
||||
if host_or_target is target:
|
||||
pp_var = {
|
||||
'C': 'CPP',
|
||||
'C++': 'CXXCPP',
|
||||
@ -1079,7 +1079,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
|
||||
log.warning('The value of %s is not used by this build system.'
|
||||
% linker_var)
|
||||
|
||||
if host_or_target == target:
|
||||
if host_or_target is target:
|
||||
@depends(valid_compiler)
|
||||
def is_msvc(compiler):
|
||||
return compiler.type == 'msvc'
|
||||
|
@ -169,7 +169,7 @@ def so_version(value):
|
||||
|
||||
@template
|
||||
def library_name_info_template(host_or_target):
|
||||
assert host_or_target in (host, target)
|
||||
assert host_or_target in {host, target}
|
||||
compiler = {
|
||||
host: host_c_compiler,
|
||||
target: c_compiler,
|
||||
|
@ -66,6 +66,31 @@ class SandboxDependsFunction(object):
|
||||
'with another @depends function.')
|
||||
return self._and(other).sandboxed
|
||||
|
||||
def __cmp__(self, other):
|
||||
raise ConfigureError('Cannot compare @depends functions.')
|
||||
|
||||
def __eq__(self, other):
|
||||
raise ConfigureError('Cannot compare @depends functions.')
|
||||
|
||||
def __ne__(self, other):
|
||||
raise ConfigureError('Cannot compare @depends functions.')
|
||||
|
||||
def __lt__(self, other):
|
||||
raise ConfigureError('Cannot compare @depends functions.')
|
||||
|
||||
def __le__(self, other):
|
||||
raise ConfigureError('Cannot compare @depends functions.')
|
||||
|
||||
def __gt__(self, other):
|
||||
raise ConfigureError('Cannot compare @depends functions.')
|
||||
|
||||
def __ge__(self, other):
|
||||
raise ConfigureError('Cannot compare @depends functions.')
|
||||
|
||||
def __nonzero__(self):
|
||||
raise ConfigureError('Cannot use @depends functions in '
|
||||
'e.g. conditionals.')
|
||||
|
||||
def __getattr__(self, key):
|
||||
return self._getattr(key).sandboxed
|
||||
|
||||
|
@ -734,18 +734,6 @@ set_config('MOZ_IPDL_TESTS',
|
||||
|
||||
include('nss.configure')
|
||||
|
||||
# LibSecret
|
||||
# ==============================================================
|
||||
# To access the OS key store on Linux systems we use libsecret.
|
||||
# https://developer.gnome.org/libsecret/
|
||||
|
||||
if target.os == 'Linux':
|
||||
libsecret = pkg_check_modules('MOZ_LIB_SECRET', 'libsecret-1',
|
||||
allow_missing=True)
|
||||
|
||||
set_config('MOZ_LIB_SECRET', depends_if(libsecret)(lambda _: True))
|
||||
set_define('MOZ_LIB_SECRET', depends_if(libsecret)(lambda _: True))
|
||||
|
||||
# Graphics
|
||||
# ==============================================================
|
||||
option('--disable-skia', help='Disable use of Skia')
|
||||
|
Loading…
Reference in New Issue
Block a user