Bug 846540 - Emasculate comm-central/configure.in, part 3: (effectively) eliminate autoconf.mk. r=Standard8, gps
authorJoshua Cranmer <Pidgeot18@gmail.com>
Sun, 31 Mar 2013 00:29:30 -0500
changeset 15385 46356c9afbfdd43e355d88a20599602d529ad102
parent 15384 660427430cdd7dd6688e0ede44e3137926c2b665
child 15386 463b6050612089df176deb0b9cdeb4fa77332330
push id920
push userbugzilla@standard8.plus.com
push dateMon, 24 Jun 2013 19:03:14 +0000
treeherdercomm-beta@936bfe9d120b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, gps
bugs846540
Bug 846540 - Emasculate comm-central/configure.in, part 3: (effectively) eliminate autoconf.mk. r=Standard8, gps
configure.in
--- a/configure.in
+++ b/configure.in
@@ -6321,16 +6321,76 @@ case "$host" in
     ;;
 *)
     FIXED_EGREP="egrep"
     ;;
 esac
 
 AC_OUTPUT([config/autoconf.mk])
 
+# Build the config.status for comm-central
+changequote(<<<,>>>)dnl
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#!${PYTHON}
+
+import os
+topsrcdir = '''${WIN_TOP_SRC:-$srcdir}'''
+if not os.path.isabs(topsrcdir):
+    rel = os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir)
+    topsrcdir = os.path.normpath(os.path.abspath(rel))
+
+topobjdir = os.path.dirname(<<<__file__>>>)
+
+from mozbuild.backend.configenvironment import BuildConfig
+mozfile = os.path.join(topobjdir, 'mozilla', 'config.status')
+mozbuildcfg = BuildConfig.from_config_status(mozfile)
+
+dnl No need to tweak these from mozilla-central
+defines = mozbuildcfg.defines
+non_global_defines = mozbuildcfg.non_global_defines
+
+dnl Fix up substitutitons
+def remap_subst(pair):
+    name, value = pair
+    value = value.replace('\$(DEPTH)', '\$(DEPTH)/mozilla')
+    value = value.replace('\$(topsrcdir)', '\$(topsrcdir)/mozilla')
+    if name == 'ac_configure_args':
+        value = r''' $ac_configure_args '''[1:-1]
+    elif name in ['MOZ_BRANDING_DIRECTORY', 'MOZ_BUILD_APP']:
+        value = value[3:] # Strip off ../ from the beginning
+    elif name in ['top_srcdir', 'MOZ_BUILD_ROOT', 'WIN_TOP_SRC']:
+        value = value[:-8] # Strip off /mozilla from the end
+    return name, value
+
+substs = map(remap_subst, mozbuildcfg.substs)
+substs.append(('COMM_BUILD', '1'))
+
+dnl These are what we output
+files = ['config/autoconf.mk']
+headers = []
+
+__all__ = ['topobjdir', 'topsrcdir', 'defines', 'non_global_defines', 'substs', 'files', 'headers']
+
+dnl Do the actual work
+if __name__ == '__main__':
+    args = dict([(name, globals()[name]) for name in __all__])
+    import sys
+dnl Don't rely on virtualenv here. Standalone js doesn't use it.
+    sys.path.append(os.path.join(topsrcdir, ${extra_python_path}'build'))
+    from ConfigStatus import config_status
+    config_status(**args)
+EOF
+changequote([,])dnl
+
+# Make the config.status file executable
+chmod +x $CONFIG_STATUS
+
 dnl ========================================================
 dnl = Setup a nice relatively clean build environment for
 dnl = sub-configures.
 dnl ========================================================
 CC="$_SUBDIR_CC" 
 CXX="$_SUBDIR_CXX" 
 CFLAGS="$_SUBDIR_CFLAGS" 
 CPPFLAGS="$_SUBDIR_CPPFLAGS"
@@ -6345,16 +6405,21 @@ unset CONFIG_FILES
 
 export WRAP_LDFLAGS
 
 if test -n "$_WRAP_MALLOC"; then
     # Avoid doubling wrap malloc arguments
     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
 fi
 
+if test -n "$UNIFY_DIST"; then
+    # Make --with-unify-dist point to the right path
+    _SUBDIR_CONFIG_ARGS="$_SUBDIR_CONFIG_ARGS --with-unify-dist=$UNIFY_DIST"
+fi
+
 # build Mozilla first
 #
 # the subdir may not yet have been created in the build tree.
 #
 if test ! -d "mozilla"; then
     mkdir "mozilla"
 fi
 
@@ -6377,8 +6442,11 @@ fi
 MOZ_BUILD_APP_CACHED="$MOZ_BUILD_APP"
 if test -n "$MOZ_CURRENT_PROJECT"; then
     export MOZ_BUILD_APP="$MOZ_CURRENT_PROJECT"
 fi
 
 AC_OUTPUT_SUBDIRS(mozilla)
 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
 MOZ_BUILD_APP="$MOZ_BUILD_APP_CACHED"
+
+# Build the comm-central files with config.status
+test "$no_create" = yes || ${PYTHON} $CONFIG_STATUS || exit 1