Bug 1207897 - Add a configure option to build multiple build backends. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Sep 2015 08:29:46 +0900
changeset 297113 617e63c7c9aed85ba623dd9b47088956ea7d3b7a
parent 297112 55af918cafff6bfdfaa6a8c665e3a2bd240b52f3
child 297114 6c9db53f98d563afe40715d936f9129c05596915
push id5920
push userpaolo.mozmail@amadzone.org
push dateTue, 29 Sep 2015 13:00:45 +0000
reviewersgps
bugs1207897
milestone44.0a1
Bug 1207897 - Add a configure option to build multiple build backends. r=gps Also record what backends were requested at configure time so that running `mach build-backend` or `config.status` uses the same set.
build/autoconf/config.status.m4
configure.in
js/src/configure.in
python/mozbuild/mozbuild/config_status.py
python/mozbuild/mozbuild/mach_commands.py
--- a/build/autoconf/config.status.m4
+++ b/build/autoconf/config.status.m4
@@ -217,8 +217,20 @@ 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],
+[
+BUILD_BACKENDS="RecursiveMake"
+
+MOZ_ARG_ENABLE_STRING(build-backend,
+[  --enable-build-backend={AndroidEclipse,CppEclipse,VisualStudio,FasterMake}
+                         Enable additional build backends],
+[ BUILD_BACKENDS="RecursiveMake `echo $enableval | sed 's/,/ /g'`"])
+
+AC_SUBST_LIST([BUILD_BACKENDS])
+])
--- a/configure.in
+++ b/configure.in
@@ -132,16 +132,18 @@ if test "$_conflict_files"; then
 EOF
   exit 1
   break
 fi
 MOZ_BUILD_ROOT=`pwd -W 2>/dev/null || pwd`
 
 MOZ_PYTHON
 
+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)
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -120,16 +120,18 @@ dnl ====================================
 MOZ_ARG_WITH_STRING(dist-dir,
 [  --with-dist-dir=DIR     Use DIR as 'dist' staging area.  DIR may be
                           relative to the top of SpiderMonkey build tree,
                           or absolute.],
     TOP_DIST=$withval,
     TOP_DIST=dist)
 AC_SUBST(TOP_DIST)
 
+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)
--- a/python/mozbuild/mozbuild/config_status.py
+++ b/python/mozbuild/mozbuild/config_status.py
@@ -83,30 +83,40 @@ def config_status(topobjdir='.', topsrcd
     if 'CONFIG_HEADERS' in os.environ:
         raise Exception('Using the CONFIG_HEADERS environment variable is not '
             'supported.')
 
     if not os.path.isabs(topsrcdir):
         raise Exception('topsrcdir must be defined as an absolute directory: '
             '%s' % topsrcdir)
 
+    default_backends = ['RecursiveMake']
+    # We have a chicken/egg problem, where we only have a dict for substs after
+    # creating the ConfigEnvironment, which requires argument parsing to have
+    # occurred.
+    for name, value in substs:
+        if name == 'BUILD_BACKENDS':
+            default_backends = value
+            break
+
     parser = ArgumentParser()
     parser.add_argument('--recheck', dest='recheck', action='store_true',
                         help='update config.status by reconfiguring in the same conditions')
     parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
                         help='display verbose output')
     parser.add_argument('-n', dest='not_topobjdir', action='store_true',
                         help='do not consider current directory as top object directory')
     parser.add_argument('-d', '--diff', action='store_true',
                         help='print diffs of changed files.')
     parser.add_argument('-b', '--backend', nargs='+',
                         choices=['RecursiveMake', 'AndroidEclipse', 'CppEclipse',
                                  'VisualStudio', 'FasterMake'],
-                        default=['RecursiveMake'],
-                        help='what backend to build (default: RecursiveMake).')
+                        default=default_backends,
+                        help='what backend to build (default: %s).' %
+                        ' '.join(default_backends))
     options = parser.parse_args()
 
     # Without -n, the current directory is meant to be the top object directory
     if not options.not_topobjdir:
         topobjdir = os.path.abspath('.')
 
     env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
             non_global_defines=non_global_defines, substs=substs, source=source)
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -556,29 +556,31 @@ class Build(MachCommandBase):
         description='Generate a backend used to build the tree.')
     @CommandArgument('-d', '--diff', action='store_true',
         help='Show a diff of changes.')
     # It would be nice to filter the choices below based on
     # conditions, but that is for another day.
     @CommandArgument('-b', '--backend', nargs='+',
         choices=['RecursiveMake', 'AndroidEclipse', 'CppEclipse',
                  'VisualStudio', 'FasterMake'],
-        default=['RecursiveMake'],
-        help='Which backend to build (default: RecursiveMake).')
-    def build_backend(self, backend='RecursiveMake', diff=False):
+        help='Which backend to build.')
+    def build_backend(self, backend, diff=False):
         python = self.virtualenv_manager.python_path
         config_status = os.path.join(self.topobjdir, 'config.status')
 
         if not os.path.exists(config_status):
             print('config.status not found.  Please run |mach configure| '
                   'or |mach build| prior to building the %s build backend.'
                   % backend)
             return 1
 
-        args = [python, config_status, '--backend'] + backend
+        args = [python, config_status]
+        if backend:
+            args.append('--backend')
+            args.extend(backend)
         if diff:
             args.append('--diff')
 
         return self._run_command_in_objdir(args=args, pass_thru=True,
             ensure_exit_code=False)
 
 @CommandProvider
 class Doctor(MachCommandBase):