Bug 935857 - Add AC_SUBST_SET to create a set() of strings in config.status and use it for NECKO_PROTOCOLS. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 12 Nov 2013 07:52:32 +0900
changeset 169042 30a667407079c0252b8e1c005eafa2dd06ef57e6
parent 169041 23bcdbcea3faa08d1458e8dd87ca3d2d168ff01f
child 169043 260fbed9b3efc47a42a6caa46f99c69504f69e1d
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs935857
milestone28.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 935857 - Add AC_SUBST_SET to create a set() of strings in config.status and use it for NECKO_PROTOCOLS. r=gps
build/autoconf/config.status.m4
configure.in
js/src/build/autoconf/config.status.m4
netwerk/streamconv/converters/moz.build
python/mozbuild/mozbuild/backend/configenvironment.py
--- a/build/autoconf/config.status.m4
+++ b/build/autoconf/config.status.m4
@@ -5,22 +5,35 @@ dnl file, You can obtain one at http://m
 dnl For use in AC_SUBST replacement
 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_SET_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
     (''' $1 ''', r''' [$]$1 ''')
 AC_DIVERT_POP()dnl
-])])
+])])])
+
+dnl Like AC_SUBST, but makes the value available as a set in python,
+dnl with values got from the value of the environment variable, split on
+dnl whitespaces.
+define([AC_SUBST_SET],
+[ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
+[ifdef([AC_SUBST_SET_$1], ,
+[define([AC_SUBST_SET_$1], )dnl
+AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
+    (''' $1 ''', set(r''' [$]$1 '''.split()))
+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]))
@@ -75,16 +88,17 @@ echo creating $CONFIG_STATUS
 
 extra_python_path=${COMM_BUILD:+"'mozilla', "}
 
 cat > $CONFIG_STATUS <<EOF
 #!${PYTHON}
 # coding=$encoding
 
 import os
+import types
 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):
     rel = os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir)
     topsrcdir = os.path.normpath(os.path.abspath(rel))
 
 topobjdir = os.path.abspath(os.path.dirname(<<<__file__>>>))
@@ -98,17 +112,17 @@ 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] if isinstance(value, types.StringTypes) else value) 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
 
--- a/configure.in
+++ b/configure.in
@@ -8100,17 +8100,17 @@ MOZ_ARG_ENABLE_STRING(necko-protocols,
         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
     else
         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
     fi
 done],
     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
 dnl Remove dupes
 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
-AC_SUBST(NECKO_PROTOCOLS)
+AC_SUBST_SET(NECKO_PROTOCOLS)
 for p in $NECKO_PROTOCOLS; do
     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
 done
 
 dnl
 dnl option to disable necko's wifi scanner
 dnl
--- a/js/src/build/autoconf/config.status.m4
+++ b/js/src/build/autoconf/config.status.m4
@@ -5,22 +5,35 @@ dnl file, You can obtain one at http://m
 dnl For use in AC_SUBST replacement
 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_SET_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
     (''' $1 ''', r''' [$]$1 ''')
 AC_DIVERT_POP()dnl
-])])
+])])])
+
+dnl Like AC_SUBST, but makes the value available as a set in python,
+dnl with values got from the value of the environment variable, split on
+dnl whitespaces.
+define([AC_SUBST_SET],
+[ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
+[ifdef([AC_SUBST_SET_$1], ,
+[define([AC_SUBST_SET_$1], )dnl
+AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
+    (''' $1 ''', set(r''' [$]$1 '''.split()))
+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]))
@@ -75,16 +88,17 @@ echo creating $CONFIG_STATUS
 
 extra_python_path=${COMM_BUILD:+"'mozilla', "}
 
 cat > $CONFIG_STATUS <<EOF
 #!${PYTHON}
 # coding=$encoding
 
 import os
+import types
 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):
     rel = os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir)
     topsrcdir = os.path.normpath(os.path.abspath(rel))
 
 topobjdir = os.path.abspath(os.path.dirname(<<<__file__>>>))
@@ -98,17 +112,17 @@ 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] if isinstance(value, types.StringTypes) else value) 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
 
--- a/netwerk/streamconv/converters/moz.build
+++ b/netwerk/streamconv/converters/moz.build
@@ -12,17 +12,17 @@ SOURCES += [
     'nsDirIndexParser.cpp',
     'nsHTTPCompressConv.cpp',
     'nsIndexedToHTML.cpp',
     'nsMultiMixedConv.cpp',
     'nsTXTToHTMLConv.cpp',
     'nsUnknownDecoder.cpp',
 ]
 
-if CONFIG['NECKO_PROTOCOLS'].find('ftp') != -1:
+if 'ftp' in CONFIG['NECKO_PROTOCOLS']:
     SOURCES += [
         'nsFTPDirListingConv.cpp',
         'ParseFTPList.cpp',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'cocoa':
     SOURCES += [
         'nsBinHexDecoder.cpp',
--- a/python/mozbuild/mozbuild/backend/configenvironment.py
+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
@@ -3,17 +3,19 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import ntpath
 import os
 import posixpath
 import re
 import sys
 
+from collections import Iterable
 from os.path import relpath
+from types import StringTypes
 
 from mozbuild.preprocessor import Preprocessor
 
 from ..util import (
     ensureParentDir,
     FileAvoidWrite,
     ReadOnlyDict,
 )
@@ -116,37 +118,51 @@ class ConfigEnvironment(object):
         self.defines = ReadOnlyDict(defines)
         self.substs = dict(substs)
         self.topsrcdir = topsrcdir
         self.topobjdir = topobjdir
         global_defines = [name for name, value in defines
             if not name in non_global_defines]
         self.substs['ACDEFINES'] = ' '.join(['-D%s=%s' % (name,
             shell_escape(self.defines[name])) for name in global_defines])
+        def serialize(obj):
+            if isinstance(obj, StringTypes):
+                return obj
+            if isinstance(obj, Iterable):
+                return ' '.join(obj)
+            raise Exception('Unhandled type %s', type(obj))
         self.substs['ALLSUBSTS'] = '\n'.join(sorted(['%s = %s' % (name,
-            self.substs[name]) for name in self.substs if self.substs[name]]))
+            serialize(self.substs[name])) for name in self.substs if self.substs[name]]))
         self.substs['ALLEMPTYSUBSTS'] = '\n'.join(sorted(['%s =' % name
             for name in self.substs if not self.substs[name]]))
         self.substs['ALLDEFINES'] = '\n'.join(sorted(['#define %s %s' % (name,
             self.defines[name]) for name in global_defines]))
 
         self.substs = ReadOnlyDict(self.substs)
 
         # Populate a Unicode version of substs. This is an optimization to make
         # moz.build reading faster, since each sandbox needs a Unicode version
         # of these variables and doing it over a thousand times is a hotspot
         # during sandbox execution!
         # Bug 844509 tracks moving everything to Unicode.
         self.substs_unicode = {}
-        for k, v in self.substs.items():
+
+        def decode(v):
             if not isinstance(v, text_type):
                 try:
-                    v = v.decode('utf-8')
+                    return v.decode('utf-8')
                 except UnicodeDecodeError:
-                    v = v.decode('utf-8', 'replace')
+                    return v.decode('utf-8', 'replace')
+
+        for k, v in self.substs.items():
+            if not isinstance(v, StringTypes):
+                if isinstance(v, Iterable):
+                    type(v)(decode(i) for i in v)
+            elif not isinstance(v, text_type):
+                v = decode(v)
 
             self.substs_unicode[k] = v
 
         self.substs_unicode = ReadOnlyDict(self.substs_unicode)
 
     @staticmethod
     def from_config_status(path):
         config = BuildConfig.from_config_status(path)