Bug 1364428 - make stylo enabling more flexible; r=rillian

We currently have an --enable-stylo option, which when passed builds
Stylo and enables Stylo at runtime.  With an upcoming move to building
Stylo everywhere by default, but only enabling it on specific platforms,
we need something more sophisticated than a binary yes/no.

The recent WebRender support offers a model worth emulating: we modify
things so there are four possibilities:

* nothing passed (the default);
* --disable-stylo (explicitly not building);
* --enable-stylo=build (build, but do not enable by default);
* --enable-stylo (build and enable)

The last option corresponds exactly to what we have today, so there's no
change in functionality.  This patch makes the default and
--disable-stylo the same; splitting the default and --disable-stylo into
separate cases enables us to change the default behavior at some point
in the future.
This commit is contained in:
Nathan Froyd 2017-05-18 18:39:40 -04:00
Родитель 90b93c9d35
Коммит 0b54cd9c51
1 изменённых файлов: 31 добавлений и 14 удалений

Просмотреть файл

@ -612,10 +612,27 @@ simple_keyfile('Adjust SDK')
# Servo integration
# ==============================================================
option('--enable-stylo', env='STYLO_ENABLED', nargs=0,
help='Enables experimental integration with the servo style system. '
'This requires either building servo within Gecko\'s cargo phase '
'or passing --with-servo')
option('--enable-stylo', nargs='?', choices=('build',),
help='Include Stylo in the build and/or enable it at runtime')
@depends('--enable-stylo')
def stylo_config(value):
build_stylo = None
enable_stylo = None
# The default is to not build Stylo at all.
if value.origin == 'default':
pass
elif value == 'build':
build_stylo = True
elif bool(value):
build_stylo = True
enable_stylo = True
return namespace(
build = build_stylo,
enable = enable_stylo,
)
# We support setting up the appropriate options for Stylo's build-time
# bindings generation via setting LLVM_CONFIG or by providing explicit
@ -658,12 +675,12 @@ def check_minimum_llvm_config_version(llvm_config):
You can verify this by typing 'llvm-config --version'.
'''.format(version, min_version)))
@depends('--enable-stylo', '--enable-stylo-build-bindgen',
@depends(stylo_config, '--enable-stylo-build-bindgen',
llvm_config, '--with-libclang-path', '--with-clang-path')
@imports(_from='textwrap', _import='dedent')
def bindgen_config_paths(stylo_enabled, bindgen_enabled,
def bindgen_config_paths(stylo_config, bindgen_enabled,
llvm_config, libclang_path, clang_path):
if not stylo_enabled:
if not stylo_config.build:
return None
if not bindgen_enabled:
@ -692,14 +709,14 @@ def bindgen_config_paths(stylo_enabled, bindgen_enabled,
clang_path=clang_path[0],
)
@depends('--enable-stylo', bindgen_config_paths, '--enable-stylo-build-bindgen')
@depends(stylo_config, bindgen_config_paths, '--enable-stylo-build-bindgen')
@imports(_from='textwrap', _import='dedent')
def stylo(stylo_enabled, bindgen_config_paths, bindgen_enabled):
if not stylo_enabled:
def stylo(stylo_config, bindgen_config_paths, bindgen_enabled):
if not stylo_config.build:
return None
elif not bindgen_enabled:
return namespace(
enabled=bool(stylo_enabled)
build=bool(stylo_config.build)
)
elif not bindgen_config_paths:
die(dedent('''\
@ -711,14 +728,14 @@ def stylo(stylo_enabled, bindgen_config_paths, bindgen_enabled):
which may not be what you intended.'''))
return namespace(
enabled=bool(stylo_enabled),
build=bool(stylo_config.build),
libclang_path=bindgen_config_paths.libclang_path,
clang_path=bindgen_config_paths.clang_path,
bindgen_enabled=bool(bindgen_enabled),
)
set_config('MOZ_STYLO', delayed_getattr(stylo, 'enabled'))
set_define('MOZ_STYLO', delayed_getattr(stylo, 'enabled'))
set_config('MOZ_STYLO', delayed_getattr(stylo, 'build'))
set_define('MOZ_STYLO', delayed_getattr(stylo, 'build'))
set_config('MOZ_LIBCLANG_PATH', delayed_getattr(stylo, 'libclang_path'))
set_config('MOZ_CLANG_PATH', delayed_getattr(stylo, 'clang_path'))