Bug 1253553 - Move --enable-artifact-builds, --disable-compile-environment and --enable-build-backend to moz.configure. r=nalexander,r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 04 Mar 2016 18:02:39 +0900
changeset 314259 addd5fc00284182a0ce28d302535266d7ef6faea
parent 314258 33859b1a30fa988aed77d3260daee09ade2c938c
child 314260 1d161d4e6cc58c8ab3c90b4b52eb28fe7020ca60
push idunknown
push userunknown
push dateunknown
reviewersnalexander, chmanchester
bugs1253553
milestone47.0a1
Bug 1253553 - Move --enable-artifact-builds, --disable-compile-environment and --enable-build-backend to moz.configure. r=nalexander,r=chmanchester Note I'm using raw primitives until patterns emerge and we decide on some helpers.
build/autoconf/config.status.m4
build/moz.configure/old.configure
build/moz.configure/util.configure
js/src/old-configure.in
moz.configure
old-configure.in
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/backend/common.py
python/mozbuild/mozbuild/test/frontend/test_emitter.py
--- a/build/autoconf/config.status.m4
+++ b/build/autoconf/config.status.m4
@@ -175,26 +175,8 @@ m4exit(1)
 define([AC_OUTPUT], [ifelse($#_$1, 1_, [MOZ_CREATE_CONFIG_STATUS()
 MOZ_RUN_CONFIG_STATUS()],
 [m4_fatal([Use CONFIGURE_SUBST_FILES in moz.build files to create substituted files.])]
 )])
 
 define([AC_CONFIG_HEADER],
 [m4_fatal([Use CONFIGURE_DEFINE_FILES in moz.build files to produce header files.])
 ])
-
-define([MOZ_BUILD_BACKEND],
-[
-dnl For now, only enable the unified hybrid build system on artifact builds,
-dnl otherwise default to RecursiveMake /and/ FasterMake.
-if test -n "$MOZ_ARTIFACT_BUILDS"; then
-    BUILD_BACKENDS="FasterMake+RecursiveMake"
-else
-    BUILD_BACKENDS="RecursiveMake FasterMake"
-fi
-
-MOZ_ARG_ENABLE_STRING(build-backend,
-[  --enable-build-backend={$($(dirname ]$[0)/$1/mach python -c "from mozbuild.backend import backends; print ','.join(sorted(backends))")}
-                         Enable additional build backends],
-[ BUILD_BACKENDS="$BUILD_BACKENDS `echo $enableval | sed 's/,/ /g'`"])
-
-AC_SUBST_SET([BUILD_BACKENDS])
-])
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -55,20 +55,20 @@ def autoconf(mozconfig, autoconf):
 
     set_config('AUTOCONF', autoconf)
     return autoconf
 
 
 option(env='OLD_CONFIGURE', nargs=1, help='Path to the old configure script')
 
 @depends('OLD_CONFIGURE', mozconfig, autoconf, check_build_environment, shell,
-         virtualenv_python)
+         virtualenv_python, compile_environment)
 @advanced
 def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
-                      python):
+                      python, compile_env):
     import glob
     import itertools
     import subprocess
     import sys
     # Import getmtime without overwriting the sandbox os.path.
     from os.path import getmtime
 
     from mozbuild.shellutil import quote
@@ -119,16 +119,18 @@ def prepare_configure(old_configure, moz
                 print("%s=%s" % (key, quote(value)), file=out)
             for key, (old, value) in mozconfig['vars']['modified'].items():
                 print("%s=%s" % (key, quote(value)), file=out)
             for t in ('env', 'vars'):
                 for key in mozconfig[t]['removed'].keys():
                     print("unset %s" % key, file=out)
 
         print('PYTHON=%s' % quote(python), file=out)
+        if compile_env:
+            print('COMPILE_ENVIRONMENT=1', file=out)
 
     return cmd
 
 
 @template
 def old_configure_options(*options):
     for opt in options:
         option(opt, nargs='*', help='Help missing for old configure options')
@@ -145,26 +147,23 @@ def old_configure_options(*options):
     '--enable-accessibility',
     '--enable-address-sanitizer',
     '--enable-alsa',
     '--enable-android-apz',
     '--enable-android-omx',
     '--enable-android-resource-constrained',
     '--enable-application',
     '--enable-approximate-location',
-    '--enable-artifact-builds',
     '--enable-b2g-bt',
     '--enable-b2g-camera',
     '--enable-b2g-ril',
-    '--enable-build-backend',
     '--enable-bundled-fonts',
     '--enable-callgrind',
     '--enable-chrome-format',
     '--enable-clang-plugin',
-    '--enable-compile-environment',
     '--enable-content-sandbox',
     '--enable-cookies',
     '--enable-cpp-rtti',
     '--enable-crashreporter',
     '--enable-ctypes',
     '--enable-dbm',
     '--enable-dbus',
     '--enable-debug',
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -62,8 +62,17 @@ def set_define(name, value):
     @advanced
     def _add_define(defines):
         from mozbuild.configure import ConfigureError
         if name in defines:
             raise ConfigureError("'%s' is already defined" % name)
         defines[name] = value
 
 del _defines
+
+
+@template
+def unique_list(l):
+    result = []
+    for i in l:
+        if l not in result:
+            result.append(i)
+    return result
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -73,27 +73,18 @@ USE_PTHREADS=
 
 dnl Do not allow objdir == srcdir builds
 dnl ==============================================================
 _topsrcdir=`cd $srcdir; pwd -W 2>/dev/null || pwd -P`
 _objdir=`pwd -P`
 
 MOZ_BUILD_ROOT=`pwd -W 2>/dev/null || pwd -P`
 
-MOZ_BUILD_BACKEND(../..)
-
 MOZ_DEFAULT_COMPILER
 
-COMPILE_ENVIRONMENT=1
-MOZ_ARG_DISABLE_BOOL(compile-environment,
-[  --disable-compile-environment
-                          Disable compiler/library checks.],
-    COMPILE_ENVIRONMENT= )
-AC_SUBST(COMPILE_ENVIRONMENT)
-
 dnl Check for Perl first -- needed for win32 SDK checks
 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
 if test -z "$PERL" -o "$PERL" = ":"; then
     AC_MSG_ERROR([perl not found in \$PATH])
 fi
 
 MOZ_ARG_ENABLE_BOOL(shared-js,
 [  --disable-shared-js
--- a/moz.configure
+++ b/moz.configure
@@ -1,10 +1,52 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 include('build/moz.configure/init.configure')
 
+
+option('--enable-artifact-builds', env='MOZ_ARTIFACT_BUILDS',
+       help='Download and use prebuilt binary artifacts.')
+
+@depends('--enable-artifact-builds')
+def artifact_builds(value):
+    if value:
+        imply_option('--disable-compile-environment')
+        set_config('MOZ_ARTIFACT_BUILDS', '1')
+    return bool(value)
+
+
+option('--disable-compile-environment',
+       help='Disable compiler/library checks')
+
+@depends('--disable-compile-environment')
+def compile_environment(value):
+    if value:
+        set_config('COMPILE_ENVIRONMENT', '1')
+    return bool(value)
+
+
+@depends('--help')
+@advanced
+def build_backends_choices(help):
+    from mozbuild.backend import backends
+    return tuple(backends)
+
+
+option('--enable-build-backend', nargs='+', choices=build_backends_choices,
+       help='Enable additional build backends')
+
+@depends('--enable-build-backend', '--enable-artifact-builds')
+def build_backend(backends, artifact_builds):
+    if artifact_builds:
+        all_backends = ['FasterMake+RecursiveMake']
+    else:
+        all_backends = ['RecursiveMake', 'FasterMake']
+    all_backends.extend(backends)
+    set_config('BUILD_BACKENDS', unique_list(all_backends))
+
+
 # Fallthrough to autoconf-based configure
 include('build/moz.configure/old.configure')
--- a/old-configure.in
+++ b/old-configure.in
@@ -96,37 +96,16 @@ dnl ====================================
 _topsrcdir=`cd \`dirname $0\`; pwd -W 2>/dev/null || pwd -P`
 _objdir=`pwd -P`
 
 MOZ_BUILD_ROOT=`pwd -W 2>/dev/null || pwd -P`
 DIST="$MOZ_BUILD_ROOT/dist"
 
 MOZ_DEFAULT_COMPILER
 
-COMPILE_ENVIRONMENT=1
-MOZ_ARG_DISABLE_BOOL(compile-environment,
-[  --disable-compile-environment
-                          Disable compiler/library checks.],
-    COMPILE_ENVIRONMENT= )
-AC_SUBST(COMPILE_ENVIRONMENT)
-
-MOZ_ARG_ENABLE_BOOL(artifact-builds,
-[  --enable-artifact-builds
-                          Download and use prebuilt binary artifacts.],
-    MOZ_ARTIFACT_BUILDS=1,
-    MOZ_ARTIFACT_BUILDS= )
-AC_SUBST(MOZ_ARTIFACT_BUILDS)
-
-if test -n "$MOZ_ARTIFACT_BUILDS"; then
-    dnl Artifact builds imply --disable-compile-environment.
-    COMPILE_ENVIRONMENT=
-fi
-
-MOZ_BUILD_BACKEND(.)
-
 MOZ_ARG_WITH_STRING(l10n-base,
 [  --with-l10n-base=DIR    path to l10n repositories],
     L10NBASEDIR=$withval)
 if test -n "$L10NBASEDIR"; then
     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
         AC_MSG_ERROR([--with-l10n-base must specify a path])
     elif test -d "$L10NBASEDIR"; then
         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd -P`
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -173,19 +173,18 @@ class TreeMetadataEmitter(LoggingMixin):
                 objs = list(self.emit_from_context(out))
                 self._emitter_time += time.time() - start
 
                 for o in emit_objs(objs): yield o
 
             else:
                 raise Exception('Unhandled output type: %s' % type(out))
 
-        # Don't emit Linkable objects when COMPILE_ENVIRONMENT is explicitely
-        # set to a value meaning false (usually '').
-        if self.config.substs.get('COMPILE_ENVIRONMENT', True):
+        # Don't emit Linkable objects when COMPILE_ENVIRONMENT is not set
+        if self.config.substs.get('COMPILE_ENVIRONMENT'):
             start = time.time()
             objs = list(self._emit_libs_derived(contexts))
             self._emitter_time += time.time() - start
 
             for o in emit_objs(objs): yield o
 
     def _emit_libs_derived(self, contexts):
         # First do FINAL_LIBRARY linkage.
--- a/python/mozbuild/mozbuild/test/backend/common.py
+++ b/python/mozbuild/mozbuild/test/backend/common.py
@@ -44,16 +44,17 @@ CONFIGS = defaultdict(lambda: {
         },
     },
     'binary-components': {
         'defines': {},
         'non_global_defines': [],
         'substs': {
             'LIB_PREFIX': 'lib',
             'LIB_SUFFIX': 'a',
+            'COMPILE_ENVIRONMENT': '1',
         },
     },
     'sources': {
         'defines': {},
         'non_global_defines': [],
         'substs': {
             'LIB_PREFIX': 'lib',
             'LIB_SUFFIX': 'a',
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -65,16 +65,17 @@ class TestEmitterBasic(unittest.TestCase
         os.environ.clear()
         os.environ.update(self._old_env)
 
     def reader(self, name, enable_tests=False):
         config = MockConfig(mozpath.join(data_path, name), extra_substs=dict(
             ENABLE_TESTS='1' if enable_tests else '',
             BIN_SUFFIX='.prog',
             OS_TARGET='WINNT',
+            COMPILE_ENVIRONMENT='1',
         ))
 
         return BuildReader(config)
 
     def read_topsrcdir(self, reader, filter_common=True):
         emitter = TreeMetadataEmitter(reader.config)
         objs = list(emitter.emit(reader.read_topsrcdir()))
         self.assertGreater(len(objs), 0)