Bug 1253553 - Move --enable-artifact-builds, --disable-compile-environment and --enable-build-backend to moz.configure draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 04 Mar 2016 18:02:39 +0900
changeset 336872 9fc8daff8e20526306a1d88fb3dd25b51c530797
parent 336864 8305d2eb45174099b7e7b5d5b4faa34509cc853c
child 515517 4cb32bf6bd31581aa48d3d0bc58a68801583c808
push id12203
push userbmo:mh+mozilla@glandium.org
push dateFri, 04 Mar 2016 09:50:36 +0000
bugs1253553
milestone47.0a1
Bug 1253553 - Move --enable-artifact-builds, --disable-compile-environment and --enable-build-backend to moz.configure 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
--- 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
@@ -60,8 +60,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`