Bug 785871 - Make config.status importable. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 29 Aug 2012 08:55:58 +0200
changeset 103742 2f3daa00593ce295e50736d647f32e6a6d6934bc
parent 103741 c2e464e9524b528129e67204c6cb11af52dc2422
child 103743 418d50c7c3a574def2667ce9a00bd5a8ee6bb7cc
push id14144
push usermh@glandium.org
push dateWed, 29 Aug 2012 06:57:06 +0000
treeherdermozilla-inbound@2f3daa00593c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs785871
milestone18.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 785871 - Make config.status importable. r=gps
Makefile.in
build/autoconf/config.status.m4
js/src/Makefile.in
js/src/build/autoconf/config.status.m4
--- a/Makefile.in
+++ b/Makefile.in
@@ -64,17 +64,17 @@ endif
 ifdef COMPILE_ENVIRONMENT
 include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
 endif
 
 
 include $(topsrcdir)/config/config.mk
 
 GARBAGE_DIRS += dist _javagen _profile _tests staticlib
-DIST_GARBAGE = config.cache config.log config.status config-defs.h \
+DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
    config/autoconf.mk \
    unallmakefiles mozilla-config.h \
    netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
    $(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out
 
 default alldep all:: $(topsrcdir)/configure config.status
 	$(RM) -r $(DIST)/sdk
 	$(RM) -r $(DIST)/include
--- a/build/autoconf/config.status.m4
+++ b/build/autoconf/config.status.m4
@@ -8,40 +8,40 @@ define([MOZ_DIVERSION_SUBST], 11)
 dnl Replace AC_SUBST to store values in a format suitable for python.
 dnl The necessary comma after the tuple can't be put here because it
 dnl can mess around with things like:
 dnl    AC_SOMETHING(foo,AC_SUBST(),bar)
 define([AC_SUBST],
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
-        (''' $1 ''', r''' [$]$1 ''')
+    (''' $1 ''', r''' [$]$1 ''')
 AC_DIVERT_POP()dnl
 ])])
 
 dnl Wrap AC_DEFINE to store values in a format suitable for python.
 dnl autoconf's AC_DEFINE still needs to be used to fill confdefs.h,
 dnl which is #included during some compile checks.
 dnl The necessary comma after the tuple can't be put here because it
 dnl can mess around with things like:
 dnl    AC_SOMETHING(foo,AC_DEFINE(),bar)
 define([_MOZ_AC_DEFINE], defn([AC_DEFINE]))
 define([AC_DEFINE],
 [cat >> confdefs.pytmp <<\EOF
-        (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
+    (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
 EOF
 ifelse($#, 2, _MOZ_AC_DEFINE([$1], [$2]), $#, 3, _MOZ_AC_DEFINE([$1], [$2], [$3]),_MOZ_AC_DEFINE([$1]))dnl
 ])
 
 dnl Wrap AC_DEFINE_UNQUOTED to store values in a format suitable for
 dnl python.
 define([_MOZ_AC_DEFINE_UNQUOTED], defn([AC_DEFINE_UNQUOTED]))
 define([AC_DEFINE_UNQUOTED],
 [cat >> confdefs.pytmp <<EOF
-        (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
+    (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
 EOF
 ifelse($#, 2, _MOZ_AC_DEFINE_UNQUOTED($1, $2), $#, 3, _MOZ_AC_DEFINE_UNQUOTED($1, $2, $3),_MOZ_AC_DEFINE_UNQUOTED($1))dnl
 ])
 
 dnl Replace AC_OUTPUT to create and call a python config.status
 define([AC_OUTPUT],
 [dnl Top source directory in Windows format (as opposed to msys format).
 WIN_TOP_SRC=
@@ -75,98 +75,100 @@ changequote(<<<, >>>)dnl
 echo creating $CONFIG_STATUS
 
 extra_python_path=${COMM_BUILD:+"'mozilla', "}
 
 cat > $CONFIG_STATUS <<EOF
 #!${PYTHON}
 # coding=$encoding
 
-import os, sys
+import os
 dnl topsrcdir is the top source directory in native form, as opposed to a
 dnl form suitable for make.
 topsrcdir = '''${WIN_TOP_SRC:-$srcdir}'''
 if not os.path.isabs(topsrcdir):
     topsrcdir = os.path.normpath(os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir))
-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
 
-args = {
-    'topsrcdir': topsrcdir,
-    'topobjdir': os.path.dirname(<<<__file__>>>),
+topobjdir = os.path.dirname(<<<__file__>>>)
 
 dnl All defines and substs are stored with an additional space at the beginning
 dnl and at the end of the string, to avoid any problem with values starting or
 dnl ending with quotes.
-    'defines': [(name[1:-1], value[1:-1]) for name, value in [
+defines = [(name[1:-1], value[1:-1]) for name, value in [
 EOF
 
 dnl confdefs.pytmp contains AC_DEFINEs, in the expected format, but
 dnl lacks the final comma (see above).
 sed 's/$/,/' confdefs.pytmp >> $CONFIG_STATUS
 rm confdefs.pytmp confdefs.h
 
 cat >> $CONFIG_STATUS <<\EOF
-    ] ],
+] ]
 
-    'substs': [(name[1:-1], value[1:-1]) for name, value in [
+substs = [(name[1:-1], value[1:-1]) for name, value in [
 EOF
 
 dnl The MOZ_DIVERSION_SUBST output diversion contains AC_SUBSTs, in the
 dnl expected format, but lacks the final comma (see above).
 sed 's/$/,/' >> $CONFIG_STATUS <<EOF
 undivert(MOZ_DIVERSION_SUBST)dnl
 EOF
 
 cat >> $CONFIG_STATUS <<\EOF
-    ] ],
+] ]
 
 dnl List of files to apply AC_SUBSTs to. This is the list of files given
 dnl as an argument to AC_OUTPUT ($1)
-    'files': [
+files = [
 EOF
 
 for out in $1; do
-  echo "        '$out'," >> $CONFIG_STATUS
+  echo "    '$out'," >> $CONFIG_STATUS
 done
 
 cat >> $CONFIG_STATUS <<\EOF
-    ],
+]
 
 dnl List of header files to apply AC_DEFINEs to. This is stored in the
 dnl AC_LIST_HEADER m4 macro by AC_CONFIG_HEADER.
-    'headers': [
+headers = [
 EOF
 
 ifdef(<<<AC_LIST_HEADER>>>, <<<
 HEADERS="AC_LIST_HEADER"
 for header in $HEADERS; do
-  echo "        '$header'," >> $CONFIG_STATUS
+  echo "    '$header'," >> $CONFIG_STATUS
 done
 >>>)dnl
 
 cat >> $CONFIG_STATUS <<\EOF
-    ],
+]
 
 dnl List of AC_DEFINEs that aren't to be exposed in ALLDEFINES
-    'non_global_defines': [
+non_global_defines = [
 EOF
 
 if test -n "$_NON_GLOBAL_ACDEFINES"; then
   for var in $_NON_GLOBAL_ACDEFINES; do
-    echo "        '$var'," >> $CONFIG_STATUS
+    echo "    '$var'," >> $CONFIG_STATUS
   done
 fi
 
-cat >> $CONFIG_STATUS <<\EOF
-    ]
-}
+cat >> $CONFIG_STATUS <<EOF
+]
+
+__all__ = ['topobjdir', 'topsrcdir', 'defines', 'non_global_defines', 'substs', 'files', 'headers']
 
 dnl Do the actual work
-config_status(**args)
+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([, ])
 chmod +x $CONFIG_STATUS
 rm -fr confdefs* $ac_clean_files
 dnl Execute config.status, unless --no-create was passed to configure.
 test "$no_create" = yes || ${PYTHON} $CONFIG_STATUS || exit 1
 ])
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -590,17 +590,17 @@ ifeq ($(OS_ARCH),WINNT)
 ifdef ENABLE_METHODJIT
 endif
 else
 ifndef HAVE_DTRACE
 #check:: check-jstests
 endif
 endif
 
-DIST_GARBAGE = config.cache config.log config.status \
+DIST_GARBAGE = config.cache config.log config.status* \
    config/autoconf.mk \
    unallmakefiles js-config js-config.h js-confdefs.h
 
 distclean::
 	cat unallmakefiles | $(XARGS) rm -f
 	$(RM) $(DIST_GARBAGE)
 
 DEFINES		+= -DEXPORT_JS_API
--- a/js/src/build/autoconf/config.status.m4
+++ b/js/src/build/autoconf/config.status.m4
@@ -8,40 +8,40 @@ define([MOZ_DIVERSION_SUBST], 11)
 dnl Replace AC_SUBST to store values in a format suitable for python.
 dnl The necessary comma after the tuple can't be put here because it
 dnl can mess around with things like:
 dnl    AC_SOMETHING(foo,AC_SUBST(),bar)
 define([AC_SUBST],
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
-        (''' $1 ''', r''' [$]$1 ''')
+    (''' $1 ''', r''' [$]$1 ''')
 AC_DIVERT_POP()dnl
 ])])
 
 dnl Wrap AC_DEFINE to store values in a format suitable for python.
 dnl autoconf's AC_DEFINE still needs to be used to fill confdefs.h,
 dnl which is #included during some compile checks.
 dnl The necessary comma after the tuple can't be put here because it
 dnl can mess around with things like:
 dnl    AC_SOMETHING(foo,AC_DEFINE(),bar)
 define([_MOZ_AC_DEFINE], defn([AC_DEFINE]))
 define([AC_DEFINE],
 [cat >> confdefs.pytmp <<\EOF
-        (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
+    (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
 EOF
 ifelse($#, 2, _MOZ_AC_DEFINE([$1], [$2]), $#, 3, _MOZ_AC_DEFINE([$1], [$2], [$3]),_MOZ_AC_DEFINE([$1]))dnl
 ])
 
 dnl Wrap AC_DEFINE_UNQUOTED to store values in a format suitable for
 dnl python.
 define([_MOZ_AC_DEFINE_UNQUOTED], defn([AC_DEFINE_UNQUOTED]))
 define([AC_DEFINE_UNQUOTED],
 [cat >> confdefs.pytmp <<EOF
-        (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
+    (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
 EOF
 ifelse($#, 2, _MOZ_AC_DEFINE_UNQUOTED($1, $2), $#, 3, _MOZ_AC_DEFINE_UNQUOTED($1, $2, $3),_MOZ_AC_DEFINE_UNQUOTED($1))dnl
 ])
 
 dnl Replace AC_OUTPUT to create and call a python config.status
 define([AC_OUTPUT],
 [dnl Top source directory in Windows format (as opposed to msys format).
 WIN_TOP_SRC=
@@ -75,98 +75,100 @@ changequote(<<<, >>>)dnl
 echo creating $CONFIG_STATUS
 
 extra_python_path=${COMM_BUILD:+"'mozilla', "}
 
 cat > $CONFIG_STATUS <<EOF
 #!${PYTHON}
 # coding=$encoding
 
-import os, sys
+import os
 dnl topsrcdir is the top source directory in native form, as opposed to a
 dnl form suitable for make.
 topsrcdir = '''${WIN_TOP_SRC:-$srcdir}'''
 if not os.path.isabs(topsrcdir):
     topsrcdir = os.path.normpath(os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir))
-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
 
-args = {
-    'topsrcdir': topsrcdir,
-    'topobjdir': os.path.dirname(<<<__file__>>>),
+topobjdir = os.path.dirname(<<<__file__>>>)
 
 dnl All defines and substs are stored with an additional space at the beginning
 dnl and at the end of the string, to avoid any problem with values starting or
 dnl ending with quotes.
-    'defines': [(name[1:-1], value[1:-1]) for name, value in [
+defines = [(name[1:-1], value[1:-1]) for name, value in [
 EOF
 
 dnl confdefs.pytmp contains AC_DEFINEs, in the expected format, but
 dnl lacks the final comma (see above).
 sed 's/$/,/' confdefs.pytmp >> $CONFIG_STATUS
 rm confdefs.pytmp confdefs.h
 
 cat >> $CONFIG_STATUS <<\EOF
-    ] ],
+] ]
 
-    'substs': [(name[1:-1], value[1:-1]) for name, value in [
+substs = [(name[1:-1], value[1:-1]) for name, value in [
 EOF
 
 dnl The MOZ_DIVERSION_SUBST output diversion contains AC_SUBSTs, in the
 dnl expected format, but lacks the final comma (see above).
 sed 's/$/,/' >> $CONFIG_STATUS <<EOF
 undivert(MOZ_DIVERSION_SUBST)dnl
 EOF
 
 cat >> $CONFIG_STATUS <<\EOF
-    ] ],
+] ]
 
 dnl List of files to apply AC_SUBSTs to. This is the list of files given
 dnl as an argument to AC_OUTPUT ($1)
-    'files': [
+files = [
 EOF
 
 for out in $1; do
-  echo "        '$out'," >> $CONFIG_STATUS
+  echo "    '$out'," >> $CONFIG_STATUS
 done
 
 cat >> $CONFIG_STATUS <<\EOF
-    ],
+]
 
 dnl List of header files to apply AC_DEFINEs to. This is stored in the
 dnl AC_LIST_HEADER m4 macro by AC_CONFIG_HEADER.
-    'headers': [
+headers = [
 EOF
 
 ifdef(<<<AC_LIST_HEADER>>>, <<<
 HEADERS="AC_LIST_HEADER"
 for header in $HEADERS; do
-  echo "        '$header'," >> $CONFIG_STATUS
+  echo "    '$header'," >> $CONFIG_STATUS
 done
 >>>)dnl
 
 cat >> $CONFIG_STATUS <<\EOF
-    ],
+]
 
 dnl List of AC_DEFINEs that aren't to be exposed in ALLDEFINES
-    'non_global_defines': [
+non_global_defines = [
 EOF
 
 if test -n "$_NON_GLOBAL_ACDEFINES"; then
   for var in $_NON_GLOBAL_ACDEFINES; do
-    echo "        '$var'," >> $CONFIG_STATUS
+    echo "    '$var'," >> $CONFIG_STATUS
   done
 fi
 
-cat >> $CONFIG_STATUS <<\EOF
-    ]
-}
+cat >> $CONFIG_STATUS <<EOF
+]
+
+__all__ = ['topobjdir', 'topsrcdir', 'defines', 'non_global_defines', 'substs', 'files', 'headers']
 
 dnl Do the actual work
-config_status(**args)
+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([, ])
 chmod +x $CONFIG_STATUS
 rm -fr confdefs* $ac_clean_files
 dnl Execute config.status, unless --no-create was passed to configure.
 test "$no_create" = yes || ${PYTHON} $CONFIG_STATUS || exit 1
 ])