Bug 1257516 - Rename error() to die() and make it take arguments like the logging module. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Mar 2016 15:48:21 +0900
changeset 290912 f97bcb2eaf41b62bb7d222f8a627a45e17fbbf54
parent 290911 c7c29d57b6c8f55cc989bc56c6a4fa3f4c9b7d06
child 290913 12248651d3ad2a6bacd79106899ec6464fd68e37
push id30128
push userkwierso@gmail.com
push dateThu, 31 Mar 2016 20:04:34 +0000
treeherdermozilla-central@bccb11375f2a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1257516
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1257516 - Rename error() to die() and make it take arguments like the logging module. r=ted
b2g/common.configure
build/moz.configure/checks.configure
build/moz.configure/init.configure
build/moz.configure/old.configure
build/moz.configure/toolchain.configure
build/moz.configure/util.configure
js/moz.configure
mobile/android/gradle.configure
moz.configure
toolkit/moz.configure
--- a/b2g/common.configure
+++ b/b2g/common.configure
@@ -8,17 +8,17 @@
 # ==============================================================
 option(env='MOZTTDIR', nargs=1, help='Path to truetype fonts for B2G')
 
 @depends('MOZTTDIR')
 def mozttdir(value):
     if value:
         path = value[0]
         if not os.path.isdir(path):
-            error('MOZTTDIR "%s" is not a valid directory' % path)
+            die('MOZTTDIR "%s" is not a valid directory', path)
         return path
 
 set_config('MOZTTDIR', mozttdir)
 
 @depends('MOZTTDIR')
 def package_moztt(value):
     if value:
         return True
--- a/build/moz.configure/checks.configure
+++ b/build/moz.configure/checks.configure
@@ -69,18 +69,18 @@ def check_prog(var, progs, allow_missing
             if result:
                 return result
 
     @depends(check, var)
     @advanced
     def postcheck(value, raw_value):
         if value is None and (not allow_missing or raw_value):
             from mozbuild.shellutil import quote
-            error('Cannot find %s (tried: %s)'
-                  % (var.lower(), ', '.join(quote(p) for p in progs)))
+            die('Cannot find %s (tried: %s)', var.lower(),
+                ', '.join(quote(p) for p in progs))
 
     @depends(check)
     def normalized_for_config(value):
         return ':' if value is None else value
 
     set_config(var, normalized_for_config)
 
     return check
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -27,36 +27,34 @@ def check_build_environment(help, dist):
         topobjdir=topobjdir,
         dist=dist,
     )
 
     if help:
         return result
 
     if topsrcdir == topobjdir:
-        error(
-            '  ***\n'
+        die('  ***\n'
             '  * Building directly in the main source directory is not allowed.\n'
             '  *\n'
             '  * To build, you must run configure from a separate directory\n'
             '  * (referred to as an object directory).\n'
             '  *\n'
             '  * If you are building with a mozconfig, you will need to change your\n'
             '  * mozconfig to point to a different object directory.\n'
             '  ***'
         )
 
     # Check for a couple representative files in the source tree
     conflict_files = [
         '*         %s' % f for f in ('Makefile', 'config/autoconf.mk')
         if os.path.exists(os.path.join(topsrcdir, f))
     ]
     if conflict_files:
-        error(
-            '  ***\n'
+        die('  ***\n'
             '  *   Your source tree contains these files:\n'
             '  %s\n'
             '  *   This indicates that you previously built in the source tree.\n'
             '  *   A source tree build can confuse the separate objdir build.\n'
             '  *\n'
             '  *   To clean up the source tree:\n'
             '  *     1. cd %s\n'
             '  *     2. gmake distclean\n'
@@ -85,17 +83,17 @@ option(env='MOZCONFIG', nargs=1, help='M
 # be called when --help is passed, and the mozconfig wouldn't be read.
 @depends('MOZ_CURRENT_PROJECT', 'MOZCONFIG', 'OLD_CONFIGURE',
          check_build_environment, '--help')
 @advanced
 def mozconfig(current_project, mozconfig, old_configure, build_env, help):
     from mozbuild.mozconfig import MozconfigLoader
 
     if not old_configure:
-        error('The OLD_CONFIGURE environment variable must be set')
+        die('The OLD_CONFIGURE environment variable must be set')
 
     # Don't read the mozconfig for the js configure (yay backwards
     # compatibility)
     # While the long term goal is that js and top-level use the same configure
     # and the same overall setup, including the possibility to use mozconfigs,
     # figuring out what we want to do wrt mozconfig vs. command line and
     # environment variable is not a clear-cut case, and it's more important to
     # fix the immediate problem mozconfig causes to js developers by
@@ -199,18 +197,18 @@ def virtualenv_python(env_python, build_
 
     if python:
         # If we're not in the virtualenv, we need the which module for
         # find_program.
         if normsep(sys.executable) != normsep(manager.python_path):
             sys.path.append(os.path.join(topsrcdir, 'python', 'which'))
         found_python = find_program(python)
         if not found_python:
-            error('The PYTHON environment variable does not contain '
-                  'a valid path. Cannot find %s' % python)
+            die('The PYTHON environment variable does not contain '
+                'a valid path. Cannot find %s', python)
         python = found_python
     else:
         python = sys.executable
 
     if not manager.up_to_date(python):
         warn('Creating Python environment')
         manager.build(python)
 
@@ -222,17 +220,17 @@ def virtualenv_python(env_python, build_
             del os.environ['PYTHON']
         # One would prefer to use os.execl, but that's completely borked on
         # Windows.
         sys.exit(subprocess.call([python] + sys.argv))
 
     # We are now in the virtualenv
     import distutils.sysconfig
     if not distutils.sysconfig.get_python_lib():
-        error('Could not determine python site packages directory')
+        die('Could not determine python site packages directory')
 
     return python
 
 set_config('PYTHON', virtualenv_python)
 add_old_configure_assignment('PYTHON', virtualenv_python)
 
 # Inject mozconfig options
 # ==============================================================
@@ -411,17 +409,17 @@ def split_triplet(triplet):
         canonical_os = canonical_kernel = 'DragonFly'
     elif os.startswith('freebsd'):
         canonical_os = canonical_kernel = 'FreeBSD'
     elif os.startswith('netbsd'):
         canonical_os = canonical_kernel = 'NetBSD'
     elif os.startswith('openbsd'):
         canonical_os = canonical_kernel = 'OpenBSD'
     else:
-        error('Unknown OS: %s' % os)
+        die('Unknown OS: %s' % os)
 
     # The CPU granularity is probably not enough. Moving more things from
     # old-configure will tell us if we need more
     if cpu.endswith('86') or (cpu.startswith('i') and '86' in cpu):
         canonical_cpu = 'x86'
     elif cpu in ('s390', 's390x', 'x86_64', 'ia64'):
         canonical_cpu = cpu
     elif cpu in ('powerpc64', 'ppc64', 'powerpc64le', 'ppc64le'):
@@ -627,25 +625,25 @@ option('--enable-project', nargs=1, defa
 
 option('--with-external-source-dir', env='EXTERNAL_SOURCE_DIR', nargs=1,
        help='External directory containing additional build files')
 
 @depends('--enable-project', '--with-external-source-dir',
          check_build_environment, '--help')
 def include_project_configure(project, external_source_dir, build_env, help):
     if not project:
-        error('--enable-project is required.')
+        die('--enable-project is required.')
 
     base_dir = build_env.topsrcdir
     if external_source_dir:
         base_dir = os.path.join(base_dir, external_source_dir[0])
 
     path = os.path.join(base_dir, project[0], 'moz.configure')
     if not os.path.exists(path):
-        error('Cannot find project %s' % project[0])
+        die('Cannot find project %s', project[0])
     return path
 
 @depends('--with-external-source-dir')
 def external_source_dir(value):
     if value:
         return value[0]
 
 set_config('EXTERNAL_SOURCE_DIR', external_source_dir)
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -46,20 +46,20 @@ def autoconf(mozconfig, autoconf):
         else:
             brew = find_program('brew')
             if brew:
                 autoconf = os.path.normpath(os.path.join(
                     brew, '..', '..', 'Cellar', 'autoconf213', '2.13', 'bin',
                     'autoconf213'))
 
     if not autoconf:
-        error('Could not find autoconf 2.13')
+        die('Could not find autoconf 2.13')
 
     if not os.path.exists(autoconf):
-        error('Could not find autoconf 2.13 at %s' % (autoconf,))
+        die('Could not find autoconf 2.13 at %s', autoconf)
 
     return autoconf
 
 set_config('AUTOCONF', autoconf)
 
 
 # See comment in mozconfig_options() from build/moz.configure/init.configure
 @template
@@ -69,19 +69,18 @@ def check_mozconfig_variables():
     # is a one off until old-configure is gone.
     all_options = depends.__self__._options.itervalues()
 
     @depends(early_options, wanted_mozconfig_variables)
     def check_mozconfig_variables(early_options, wanted_mozconfig_variables):
         for option in all_options:
             if (option.env and option.env not in early_options and
                     option.env not in wanted_mozconfig_variables):
-                error(
-                    'You need to add `%s` to the `wanted_mozconfig_variables` '
-                    'list in build/moz.configure/init.configure.' % option.env)
+                die('You need to add `%s` to the `wanted_mozconfig_variables` '
+                    'list in build/moz.configure/init.configure.', option.env)
 
 check_mozconfig_variables()
 
 
 @depends('OLD_CONFIGURE', mozconfig, autoconf, check_build_environment, shell,
          old_configure_assignments, build_project)
 @advanced
 def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
@@ -406,18 +405,18 @@ def old_configure(prepare_configure, ext
         # contains a nested function with free variables
         exec code in raw_config
 
     # Ensure all the flags known to old-configure appear in the
     # @old_configure_options above.
     all_options = set(all_options)
     for flag in raw_config['flags']:
         if flag not in all_options:
-            error('Missing option in `@old_configure_options` in %s: %s'
-                  % (__file__, flag))
+            die('Missing option in `@old_configure_options` in %s: %s',
+                __file__, flag)
 
     # If the code execution above fails, we want to keep the file around for
     # debugging.
     os.remove('config.data')
     return raw_config
 
 
 # set_config is only available in the global namespace, not directly in
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -14,17 +14,17 @@ yasm = check_prog('YASM', ['yasm'], allo
 def yasm_version(yasm):
     import subprocess
     try:
         version = Version(subprocess.check_output(
             [yasm, '--version']
         ).splitlines()[0].split()[1])
         return version
     except subprocess.CalledProcessError as e:
-        error('Failed to get yasm version: %s' % e.message)
+        die('Failed to get yasm version: %s', e.message)
 
 # Until we move all the yasm consumers out of old-configure.
 # bug 1257904
 add_old_configure_assignment('_YASM_MAJOR_VERSION',
                              delayed_getattr(yasm_version, 'major'))
 add_old_configure_assignment('_YASM_MINOR_VERSION',
                              delayed_getattr(yasm_version, 'minor'))
 
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -10,20 +10,20 @@ def warn(*args):
     'Print a warning.'
     import sys
     print(*args, file=sys.stderr)
     sys.stderr.flush()
 
 
 @template
 @advanced
-def error(*args):
+def die(format, *args):
     'Print an error and terminate configure.'
     import sys
-    print(*args, file=sys.stderr)
+    print(format % args, file=sys.stderr)
     sys.stderr.flush()
     sys.exit(1)
 
 
 @template
 @advanced
 def configure_error(message):
     '''Raise a programming error and terminate configure.
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -56,17 +56,17 @@ js_option('--disable-shared-js', default
 
 js_option('--disable-export-js', default=building_js,
           help='Do not mark JS symbols as DLL exported/visible')
 
 @depends('--disable-shared-js', '--disable-export-js')
 def shared_js(shared_js, export_js):
     if shared_js:
         if not export_js:
-            error('Must export JS symbols when building a shared library.')
+            die('Must export JS symbols when building a shared library.')
         return True
 
 set_config('JS_SHARED_LIBRARY', shared_js)
 add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
 
 @depends('--disable-shared-js', '--disable-export-js')
 def exportable_js_api(shared_js, export_js):
     if not shared_js and export_js:
@@ -91,41 +91,41 @@ set_define('MOZ_STATIC_JS', static_js)
 @deprecated_option(env='DISABLE_SHARED_JS', nargs='?')
 def disable_shared_js(value):
     # DISABLE_SHARED_JS=1 gets us an empty PositiveOptionValue
     if value and not len(value):
         suggestion = '--disable-shared-js'
     else:
         suggestion = '--enable-shared-js'
 
-    error('Setting %s is deprecated, use %s instead.'
-          % (value.format('DISABLE_SHARED_JS'), suggestion))
+    die('Setting %s is deprecated, use %s instead.',
+        value.format('DISABLE_SHARED_JS'), suggestion)
 
 @deprecated_option(env='DISABLE_EXPORT_JS', nargs='?')
 def disable_export_js(value):
     # DISABLE_EXPORT_JS=1 gets us an empty PositiveOptionValue
     if value and not len(value):
         suggestion = '--disable-export-js'
     else:
         suggestion = '--enable-export-js'
 
-    error('Setting %s is deprecated, use %s instead.'
-          % (value.format('DISABLE_EXPORT_JS'), suggestion))
+    die('Setting %s is deprecated, use %s instead.',
+        value.format('DISABLE_EXPORT_JS'), suggestion)
 
 
 # Profiling
 # =======================================================
 js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
           help='Enable instruments remote profiling')
 
 @depends('--enable-instruments', target)
 def instruments(value, target):
     if value and target.os != 'OSX':
-        error('--enable-instruments cannot be used when targeting %s'
-              % target.os)
+        die('--enable-instruments cannot be used when targeting %s',
+            target.os)
     if value:
         return True
 
 set_config('MOZ_INSTRUMENTS', instruments)
 set_define('MOZ_INSTRUMENTS', instruments)
 add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
 imply_option('--enable-profiling', instruments, reason='--enable-instruments')
 
--- a/mobile/android/gradle.configure
+++ b/mobile/android/gradle.configure
@@ -22,17 +22,17 @@ set_config('MOZ_BUILD_MOBILE_ANDROID_WIT
 
 @depends('--with-gradle', check_build_environment)
 def gradle(value, build_env):
     gradle = value[0] if len(value) else \
         os.path.join(build_env.topsrcdir, 'gradlew')
 
     # TODO: verify that $GRADLE is executable.
     if not os.path.isfile(gradle):
-        error('GRADLE must be executable: %s' % gradle)
+        die('GRADLE must be executable: %s', gradle)
 
     return gradle
 
 set_config('GRADLE', gradle)
 
 
 # Automation uses this to change log levels, not use the daemon, and use
 # offline mode.
--- a/moz.configure
+++ b/moz.configure
@@ -111,37 +111,37 @@ def perl_version_check(min_version):
     @depends(perl)
     @checking('for minimum required perl version >= %s' % min_version)
     @advanced
     def get_perl_version(perl):
         import subprocess
         try:
             return Version(subprocess.check_output([perl, '-e', 'print $]']))
         except subprocess.CalledProcessError as e:
-            error('Failed to get perl version: %s' % e.message)
+            die('Failed to get perl version: %s', e.message)
 
     @depends(get_perl_version)
     def check_perl_version(version):
         if version < min_version:
-            error('Perl %s or higher is required.' % min_version)
+            die('Perl %s or higher is required.', min_version)
 
     @depends(perl)
     @checking('for full perl installation')
     @advanced
     def has_full_perl_installation(perl):
         import subprocess
         ret = subprocess.call(
             [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
         return ret == 0
 
     @depends(has_full_perl_installation)
     def require_full_perl_installation(has_full_perl_installation):
         if not has_full_perl_installation:
-            error('Cannot find Config.pm or $Config{archlib}. '
-                  'A full perl installation is required.')
+            die('Cannot find Config.pm or $Config{archlib}. '
+                'A full perl installation is required.')
 
 perl_version_check('5.006')
 
 
 # Miscellaneous programs
 # ==============================================================
 check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
 check_prog('TAR', ('gnutar', 'gtar', 'tar'))
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -10,18 +10,18 @@
 # Some of the options here imply an option from js/moz.configure,
 # so, need to be declared before the include.
 option('--enable-systrace', env='MOZ_USE_SYSTRACE',
        help='Turn on systrace for the Gecko profiler on android/b2g')
 
 @depends('--enable-systrace', target)
 def systrace(value, target):
     if value and target.os != 'Android':
-        error('--enable-systrace cannot be used when targetting %s'
-              % target.os)
+        die('--enable-systrace cannot be used when targeting %s',
+            target.os)
     if value:
         return True
 
 set_define('MOZ_USE_SYSTRACE', systrace)
 
 
 option('--enable-jprof', env='MOZ_JPROF',
        help='Enable jprof profiling tool (needs mozilla/tools/jprof)')
@@ -76,17 +76,17 @@ include('../js/moz.configure')
 option('--with-l10n-base', nargs=1, env='L10NBASEDIR',
        help='Path to l10n repositories')
 
 @depends('--with-l10n-base')
 def l10n_base(value):
     if value:
         path = value[0]
         if not os.path.isdir(path):
-            error("Invalid value --with-l10n-base, %s doesn't exist" % path)
+            die("Invalid value --with-l10n-base, %s doesn't exist", path)
         return os.path.realpath(os.path.abspath(path))
 
 set_config('L10NBASEDIR', l10n_base)
 
 
 # Default toolkit
 # ==============================================================
 # Normally, we'd want to use the `default` field on the option, but that
@@ -118,20 +118,18 @@ def toolkit(value, target, gonkdir):
         else:
             platform_choices = ('cairo-android',)
     else:
         platform_choices = ('cairo-gtk3', 'cairo-gtk2', 'cairo-gtk2-x11',
                             'cairo-qt')
 
     if value:
         if value[0] not in platform_choices:
-            error(
-                '`%s` is not a valid value for --enable-default-toolkit on %s\n'
-                'Valid values: %s'
-                % (value[0], os, ', '.join(platform_choices)))
+            die('`%s` is not a valid value for --enable-default-toolkit on %s\n'
+                'Valid values: %s', value[0], os, ', '.join(platform_choices))
         return value[0]
 
     return platform_choices[0]
 
 
 @depends(toolkit)
 def toolkit(toolkit):
     if toolkit == 'cairo-gtk2-x11':
@@ -160,22 +158,22 @@ def toolkit_define(toolkit):
 set_define(toolkit_define, True)
 
 
 option('--without-x', env='WITHOUT_X', help='Disable X11 support')
 
 @depends('--without-x', toolkit)
 def x11(value, toolkit):
     if not value and toolkit != 'qt':
-        error('--without-x is only valid with --enable-default-toolkit=qt')
+        die('--without-x is only valid with --enable-default-toolkit=qt')
 
     x11_toolkits = ('gtk2', 'gtk3', 'qt')
     if value and value.origin != 'default' and toolkit not in x11_toolkits:
-        error('--with-x is only valid with --enable-default-toolkit={%s}'
-              % ','.join(x11_toolkits))
+        die('--with-x is only valid with --enable-default-toolkit={%s}',
+            ','.join(x11_toolkits))
 
     return True if value and toolkit in x11_toolkits else None
 
 set_config('MOZ_ENABLE_XREMOTE', x11)
 set_define('MOZ_ENABLE_XREMOTE', x11)
 set_config('MOZ_X11', x11)
 set_define('MOZ_X11', x11)
 add_old_configure_assignment('MOZ_X11', x11)
@@ -282,18 +280,17 @@ option('--disable-wmf',
 def wmf(value, target):
     enabled = bool(value)
     if value.origin == 'default':
         # Enable Windows Media Foundation support by default.
         # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
         # guaranteed to have a recent-enough SDK to build WMF.
         enabled = target.os == 'WINNT'
     if enabled and target.os != 'WINNT':
-        error('Cannot enable Windows Media Foundation support on %s'
-              % target.os)
+        die('Cannot enable Windows Media Foundation support on %s', target.os)
     if enabled:
         return True
 
 set_config('MOZ_WMF', wmf)
 set_define('MOZ_WMF', wmf)
 
 # FFmpeg H264/AAC Decoding Support
 # ==============================================================
@@ -336,18 +333,18 @@ option('--enable-eme', nargs='*', choice
        help='Enable support for Encrypted Media Extensions')
 
 @depends('--enable-eme', fmp4)
 def eme(value, fmp4):
     enabled = bool(value)
     if value.origin == 'default':
         enabled = enabled or fmp4
     if enabled and not fmp4:
-        error('Encrypted Media Extension support requires '
-              'Fragmented MP4 support')
+        die('Encrypted Media Extension support requires '
+            'Fragmented MP4 support')
     if enabled:
         return True
 
 @depends('--enable-eme')
 def eme_modules(value):
     # Theoretically, we could pass `value` directly when it is a
     # PositiveOptionValue, but somehow, the JSON serialization in configure.py
     # outputs inconsistent data in some cases when we do (a closing bracket