From cd326f0e814dcc28fd7ab91f2574795adafcd06c Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Tue, 16 Oct 2018 20:28:12 +0900 Subject: [PATCH] Bug 1492716 - Part 2: Add formatting rule to help text for --{enable,disable,with,without}. r=glandium Differential Revision: https://phabricator.services.mozilla.com/D8834 --- build/moz.configure/warnings.configure | 2 +- js/moz.configure | 28 +++++++++++---------- moz.configure | 3 ++- python/mozbuild/mozbuild/configure/help.py | 27 +++++++++++++++++++- toolkit/moz.configure | 29 ++++++++++++---------- toolkit/nss.configure | 3 ++- 6 files changed, 62 insertions(+), 30 deletions(-) diff --git a/build/moz.configure/warnings.configure b/build/moz.configure/warnings.configure index 9febf16dfcea..00af987d7e47 100755 --- a/build/moz.configure/warnings.configure +++ b/build/moz.configure/warnings.configure @@ -6,7 +6,7 @@ js_option('--enable-warnings-as-errors', env='MOZ_ENABLE_WARNINGS_AS_ERRORS', default=depends('MOZ_AUTOMATION', '--help')(lambda x, _: bool(x)), - help='Enable treating warnings as errors') + help='{Enable|Disable} treating warnings as errors') add_old_configure_assignment( 'MOZ_ENABLE_WARNINGS_AS_ERRORS', diff --git a/js/moz.configure b/js/moz.configure index 041829b775ca..49a90307b341 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -29,7 +29,7 @@ set_config('JS_STANDALONE', js_standalone) set_define('JS_STANDALONE', js_standalone) add_old_configure_assignment('JS_STANDALONE', js_standalone) js_option('--disable-js-shell', default=building_js, - help='Do not build the JS shell') + help='{Build|Do not build} the JS shell') @depends('--disable-js-shell') def js_disable_shell(value): @@ -47,10 +47,10 @@ set_define('JS_NUNBOX32', depends(target)(lambda t: t.bitness == 32 or None)) # SpiderMonkey as a shared library, and how its symbols are exported # ================================================================== js_option('--disable-shared-js', default=building_js, - help='Do not create a shared library') + help='{Create|Do not create} a shared library') js_option('--disable-export-js', default=building_js, - help='Do not mark JS symbols as DLL exported/visible') + help='{Mark|Do not mark} JS symbols as DLL exported/visible') @depends('--disable-shared-js', '--disable-export-js') def shared_js(shared_js, export_js): @@ -131,7 +131,7 @@ def ion_default(target, enable_bigint): js_option('--enable-ion', default=ion_default, - help='Enable use of the IonMonkey JIT') + help='{Enable|Disable} use of the IonMonkey JIT') set_config('ENABLE_ION', depends_if('--enable-ion')(lambda x: True)) @@ -263,8 +263,8 @@ def enable_profiling(milestone, help): return milestone.is_nightly js_option('--enable-profiling', env='MOZ_PROFILING', default=enable_profiling, - help='Set compile flags necessary for using sampling profilers ' - '(e.g. shark, perf)') + help='{Set|Do not set} compile flags necessary for using sampling ' + 'profilers (e.g. shark, perf)') @depends('--enable-profiling') def profiling(value): @@ -311,7 +311,7 @@ set_define('JS_GC_TRACE', gc_trace) js_option('--enable-gczeal', default=depends(when=moz_debug)(lambda: True), - help='Enable zealous GCing') + help='{Enable|Disable} zealous GCing') set_define('JS_GC_ZEAL', depends_if('--enable-gczeal')(lambda _: True)) @@ -332,7 +332,7 @@ set_define('JS_GC_SMALL_CHUNK_SIZE', # ======================================================= js_option('--enable-trace-logging', default=depends(when=moz_debug)(lambda: True), - help='Enable trace logging') + help='{Enable|Disable} trace logging') set_config('ENABLE_TRACE_LOGGING', depends_if('--enable-trace-logging')(lambda x: True)) @@ -362,7 +362,8 @@ set_define('JS_ION_PERF', ion_perf) js_option('--enable-jitspew', default=depends(when=moz_debug)(lambda: True), - help='Enable the Jit spew and IONFLAGS environment variable.') + help='{Enable|Disable} the Jit spew and IONFLAGS environment ' + 'variable') set_define('JS_JITSPEW', depends_if('--enable-jitspew')(lambda _: True)) @@ -375,7 +376,7 @@ set_config('JS_JITSPEW', # dumping registers on and off the stack. js_option('--enable-masm-verbose', default=depends(when=moz_debug)(lambda: True), - help='Enable MacroAssembler verbosity of generated code.') + help='{Enable|Disable} MacroAssembler verbosity of generated code.') set_define('JS_MASM_VERBOSE', depends_if('--enable-masm-verbose')(lambda _: True)) set_config('JS_MASM_VERBOSE', @@ -399,8 +400,9 @@ set_define('JS_MORE_DETERMINISTIC', more_deterministic) def ctypes_default(building_js, _): return not building_js -js_option('--enable-ctypes', help='Enable js-ctypes', - default=ctypes_default) +js_option('--enable-ctypes', + default=ctypes_default, + help='{Enable|Disable} js-ctypes') build_ctypes = depends_if('--enable-ctypes')(lambda _: True) @@ -504,7 +506,7 @@ def default_cranelift(is_nightly): js_option('--enable-cranelift', default=default_cranelift, - help='Enable Cranelift code generator for wasm') + help='{Enable|Disable} Cranelift code generator for wasm') set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True)) set_define('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True)) diff --git a/moz.configure b/moz.configure index c52bd1616258..baeb4e757716 100755 --- a/moz.configure +++ b/moz.configure @@ -121,7 +121,8 @@ add_old_configure_assignment('MOZ_DEBUG', js_option('--enable-rust-debug', default=depends(when='--enable-debug')(lambda: True), - help='Build Rust code with debug assertions turned on.') + help='{Build|Do not build} Rust code with debug assertions turned ' + 'on.') @depends(when='--enable-rust-debug') def debug_rust(): diff --git a/python/mozbuild/mozbuild/configure/help.py b/python/mozbuild/mozbuild/configure/help.py index cd7876fbd156..19f8e796c07e 100644 --- a/python/mozbuild/mozbuild/configure/help.py +++ b/python/mozbuild/mozbuild/configure/help.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, print_function, unicode_literals import os +import re from mozbuild.configure.options import Option @@ -26,7 +27,7 @@ class HelpFormatter(object): opt = option.option if option.choices: opt += '={%s}' % ','.join(option.choices) - help = option.help or '' + help = self.format_help(option) if len(option.default): if help: help += ' ' @@ -39,6 +40,30 @@ class HelpFormatter(object): else: target.append(' %-24s %s' % (opt, help)) + RE_FORMAT = re.compile(r'{([^|}]+)\|([^|}]+)}') + + # Return formatted help text for --{enable,disable,with,without}-* options. + # + # Format is the following syntax: + # {String for --enable or --with|String for --disable or --without} + # + # For example, '{Enable|Disable} optimizations' will be formatted to + # 'Enable optimizations' if the options's prefix is 'enable' or 'with', + # and formatted to 'Disable optimizations' if the options's prefix is + # 'disable' or 'without'. + def format_help(self, option): + if not option.help: + return '' + + if option.prefix in ('enable', 'with'): + replacement = r'\1' + elif option.prefix in ('disable', 'without'): + replacement = r'\2' + else: + return option.help + + return self.RE_FORMAT.sub(replacement, option.help) + def usage(self, out): print('\n\n'.join('\n'.join(t) for t in (self.intro, self.options, self.env)), diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 3a00baf3304d..642bcfc6638c 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -100,7 +100,7 @@ def pulseaudio_default(target): return target.os not in ('WINNT', 'OSX', 'iOS', 'Android', 'OpenBSD') option('--enable-pulseaudio', env='MOZ_PULSEAUDIO', default=pulseaudio_default, - help='Enable PulseAudio audio backend.') + help='{Enable|Disable} PulseAudio audio backend.') pulseaudio = pkg_check_modules('MOZ_PULSEAUDIO', 'libpulse', when='--enable-pulseaudio') @@ -716,7 +716,7 @@ add_old_configure_assignment('MOZ_WEBSPEECH', webspeech) # Speech API test backend # ============================================================== option('--enable-webspeechtestbackend', default=webspeech, - help='Enable support for HTML Speech API Test Backend') + help='{Enable|Disable} support for HTML Speech API Test Backend') @depends_if('--enable-webspeechtestbackend') def webspeech_test_backend(value): @@ -927,7 +927,7 @@ def geckodriver_default(enable_tests, target, cross_compile, hazard, asan): option('--enable-geckodriver', default=geckodriver_default, when='--enable-compile-environment', - help='Build geckodriver') + help='{Build|Do not build} geckodriver') @depends('--enable-geckodriver', when='--enable-compile-environment') def geckodriver(enabled): @@ -959,7 +959,7 @@ def webrtc_default(target): return False option('--disable-webrtc', default=webrtc_default, - help='Disable support for WebRTC') + help='{Enable|Disable} support for WebRTC') @depends('--disable-webrtc') def webrtc(enabled): @@ -1000,8 +1000,9 @@ def raw_media_default(target, webrtc): if webrtc: return True -option('--enable-raw', help='Enable support for RAW media', - default=raw_media_default) +option('--enable-raw', + default=raw_media_default, + help='{Enable|Disable} support for RAW media') set_config('MOZ_RAW', depends_if('--enable-raw')(lambda _: True)) set_define('MOZ_RAW', depends_if('--enable-raw')(lambda _: True)) @@ -1034,7 +1035,7 @@ with only_when('--enable-compile-environment'): with only_when(has_elfhack): option('--disable-elf-hack', default=default_elfhack, - help='Disable elf hacks') + help='{Enable|Disable} elf hacks') set_config('USE_ELF_HACK', depends_if('--enable-elf-hack')(lambda _: True)) @@ -1161,7 +1162,7 @@ def launcher_process_default(target, milestone): return target.os == 'WINNT' and milestone.is_nightly option('--enable-launcher-process', default=launcher_process_default, - help='Enable launcher process by default') + help='{Enable|Disable} launcher process by default') @depends('--enable-launcher-process', target) def launcher(value, target): @@ -1189,8 +1190,9 @@ set_config('MOZ_LIBPRIO', libprio) # Maintenance service (Windows only) # ============================================================== -option('--enable-maintenance-service', help='Enable building of maintenance service', - when=target_is_windows, default=target_is_windows) +option('--enable-maintenance-service', + when=target_is_windows, default=target_is_windows, + help='{Enable|Disable} building of maintenance service') set_define('MOZ_MAINTENANCE_SERVICE', depends_if('--enable-maintenance-service', @@ -1212,7 +1214,7 @@ def allow_bundled_fonts(project): option('--enable-bundled-fonts', default=bundled_fonts_default, when=allow_bundled_fonts, - help='Enable support for bundled fonts on desktop platforms') + help='{Enable|Disable} support for bundled fonts on desktop platforms') set_define('MOZ_BUNDLED_FONTS', depends_if('--enable-bundled-fonts', when=allow_bundled_fonts)(lambda _: True)) @@ -1243,8 +1245,9 @@ def reflow_perf(debug, _): if debug: return True -option('--enable-reflow-perf', help='Enable reflow performance tracing', - default=reflow_perf) +option('--enable-reflow-perf', + default=reflow_perf, + help='{Enable|Disable} reflow performance tracing') # The difference in conditions here comes from the initial implementation # in old-configure, which was unexplained there as well. diff --git a/toolkit/nss.configure b/toolkit/nss.configure index f910b7ba3d07..54e6d2ac2c27 100644 --- a/toolkit/nss.configure +++ b/toolkit/nss.configure @@ -11,6 +11,7 @@ def dbm_default(build_project, _): return build_project != 'mobile/android' -option('--enable-dbm', default=dbm_default, help='Enable building DBM') +option('--enable-dbm', default=dbm_default, + help='{Enable|Disable} building DBM') set_config('NSS_DISABLE_DBM', depends('--enable-dbm')(lambda x: not x))