Bug 1276003 - Move --enable-necko-protocols to python configure. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 18 Aug 2016 09:57:06 +0900
changeset 310663 f8dd2d41e245850e48eea8fe63527de6bc357756
parent 310662 8d448381edbb7d59c942979e38c1f9f09ed5270d
child 310664 35416a1541ae9860846ec93081d12b7e96c930c3
push id30592
push userryanvm@gmail.com
push dateTue, 23 Aug 2016 14:01:40 +0000
treeherdermozilla-central@a522dde88529 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1276003
milestone51.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 1276003 - Move --enable-necko-protocols to python configure. r=chmanchester
build/moz.configure/old.configure
old-configure.in
python/moz.build
python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
toolkit/moz.configure
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -194,17 +194,16 @@ def old_configure_options(*options):
     '--enable-libjpeg-turbo',
     '--enable-libproxy',
     '--enable-llvm-hacks',
     '--enable-logrefcnt',
     '--enable-maintenance-service',
     '--enable-memory-sanitizer',
     '--enable-mobile-optimize',
     '--enable-mozril-geoloc',
-    '--enable-necko-protocols',
     '--enable-necko-wifi',
     '--enable-negotiateauth',
     '--enable-nfc',
     '--enable-nspr-build',
     '--enable-official-branding',
     '--enable-omx-plugin',
     '--enable-oom-breakpoint',
     '--enable-optimize',
--- a/old-configure.in
+++ b/old-configure.in
@@ -2361,17 +2361,16 @@ MOZ_SPELLCHECK=1
 MOZ_TOOLKIT_SEARCH=1
 MOZ_UI_LOCALE=en-US
 MOZ_UNIVERSALCHARDET=1
 MOZ_URL_CLASSIFIER=
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
 MOZ_NO_SMART_CARDS=
 NECKO_COOKIES=1
-NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
 BUILD_CTYPES=1
 MOZ_USE_NATIVE_POPUP_WINDOWS=
 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
 MOZ_INSTALL_TRACKING=
 ACCESSIBILITY=1
 MOZ_TIME_MANAGER=
 MOZ_SIMPLEPUSH=
 MOZ_AUDIO_CHANNEL_MANAGER=
@@ -5484,43 +5483,16 @@ fi
 
 AC_SUBST(MOZ_XUL)
 
 dnl ========================================================
 dnl necko configuration options
 dnl ========================================================
 
 dnl
-dnl option to disable various necko protocols
-dnl
-MOZ_ARG_ENABLE_STRING(necko-protocols,
-[  --enable-necko-protocols[={http,ftp,default,all,none}]
-                          Enable/disable specific protocol handlers],
-[ for option in `echo $enableval | sed 's/,/ /g'`; do
-    if test "$option" = "yes" -o "$option" = "all"; then
-        NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
-    elif test "$option" = "no" -o "$option" = "none"; then
-        NECKO_PROTOCOLS=""
-    elif test "$option" = "default"; then
-        NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
-    elif test `echo "$option" | grep -c \^-` != 0; then
-        option=`echo $option | sed 's/^-//'`
-        NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
-    else
-        NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
-    fi
-done],
-    NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
-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
 
 case "$OS_TARGET" in
   Android)
     if test -n "$gonkdir"; then
       NECKO_WIFI=1
     fi
--- a/python/moz.build
+++ b/python/moz.build
@@ -39,16 +39,17 @@ PYTHON_UNIT_TESTS += [
     'mozbuild/mozbuild/test/compilation/test_warnings.py',
     'mozbuild/mozbuild/test/configure/test_checks_configure.py',
     'mozbuild/mozbuild/test/configure/test_compile_checks.py',
     'mozbuild/mozbuild/test/configure/test_configure.py',
     'mozbuild/mozbuild/test/configure/test_moz_configure.py',
     'mozbuild/mozbuild/test/configure/test_options.py',
     'mozbuild/mozbuild/test/configure/test_toolchain_configure.py',
     'mozbuild/mozbuild/test/configure/test_toolchain_helpers.py',
+    'mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py',
     'mozbuild/mozbuild/test/configure/test_util.py',
     'mozbuild/mozbuild/test/controller/test_ccachestats.py',
     'mozbuild/mozbuild/test/controller/test_clobber.py',
     'mozbuild/mozbuild/test/frontend/test_context.py',
     'mozbuild/mozbuild/test/frontend/test_emitter.py',
     'mozbuild/mozbuild/test/frontend/test_namespaces.py',
     'mozbuild/mozbuild/test/frontend/test_reader.py',
     'mozbuild/mozbuild/test/frontend/test_sandbox.py',
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
@@ -0,0 +1,67 @@
+# 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/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import os
+
+from buildconfig import topsrcdir
+from common import BaseConfigureTest
+from mozunit import main
+
+
+class TestToolkitMozConfigure(BaseConfigureTest):
+    def test_necko_protocols(self):
+        def get_value(arg):
+            sandbox = self.get_sandbox({}, {}, [arg])
+            return sandbox._value_for(sandbox['necko_protocols'])
+
+        default_protocols = get_value('')
+        self.assertNotEqual(default_protocols, ())
+
+        # Backwards compatibility
+        self.assertEqual(get_value('--enable-necko-protocols'),
+                         default_protocols)
+
+        self.assertEqual(get_value('--enable-necko-protocols=yes'),
+                         default_protocols)
+
+        self.assertEqual(get_value('--enable-necko-protocols=all'),
+                         default_protocols)
+
+        self.assertEqual(get_value('--enable-necko-protocols=default'),
+                         default_protocols)
+
+        self.assertEqual(get_value('--enable-necko-protocols='), ())
+
+        self.assertEqual(get_value('--enable-necko-protocols=no'), ())
+
+        self.assertEqual(get_value('--enable-necko-protocols=none'), ())
+
+        self.assertEqual(get_value('--disable-necko-protocols'), ())
+
+        self.assertEqual(get_value('--enable-necko-protocols=http'),
+                         ('http',))
+
+        self.assertEqual(get_value('--enable-necko-protocols=http,about'),
+                         ('about', 'http'))
+
+        self.assertEqual(get_value('--enable-necko-protocols=http,none'), ())
+
+        self.assertEqual(get_value('--enable-necko-protocols=-http'), ())
+
+        self.assertEqual(get_value('--enable-necko-protocols=none,http'),
+                         ('http',))
+
+        self.assertEqual(
+            get_value('--enable-necko-protocols=all,-http,-about'),
+            tuple(p for p in default_protocols if p not in ('http', 'about')))
+
+        self.assertEqual(
+            get_value('--enable-necko-protocols=default,-http,-about'),
+            tuple(p for p in default_protocols if p not in ('http', 'about')))
+
+
+if __name__ == '__main__':
+    main()
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -616,8 +616,73 @@ set_define('MOZ_WEBSMS_BACKEND', websms_
 # Enable IPDL's "expensive" unit tests
 # ==============================================================
 option('--enable-ipdl-tests', help='Enable expensive IPDL tests')
 
 set_config('MOZ_IPDL_TESTS',
            depends_if('--enable-ipdl-tests')(lambda _: True))
 
 include('nss.configure')
+
+# Network protocol support
+# ==============================================================
+@depends(check_build_environment, '--help')
+@imports('os')
+@imports(_from='__builtin__', _import='sorted')
+def all_necko_protocols(build_env, _):
+    basedir = os.path.join(build_env.topsrcdir, 'netwerk', 'protocol')
+    return tuple(sorted(p for p in os.listdir(basedir)
+                        if os.path.isdir(os.path.join(basedir, p))))
+
+default_necko_protocols = all_necko_protocols
+
+@deprecated_option('--enable-necko-protocols', nargs='*')
+def necko_protocols(protocols):
+    return protocols
+
+@depends(necko_protocols, default_necko_protocols)
+def necko_protocols(protocols, default_protocols):
+    if protocols is None or (protocols and len(protocols) == 0):
+        return None
+    if len(protocols) == 1 and protocols[0] == '':
+        return False
+    result = set()
+    for p in protocols:
+        if p in ('yes', 'all', 'default'):
+            result |= set(default_protocols)
+            continue
+        if p in ('no', 'none'):
+            result = set()
+            continue
+        if p.startswith('-'):
+            if p[1:] in result:
+                result.remove(p[1:])
+        else:
+            result.add(p)
+    if result != set(default_protocols):
+        return tuple(result)
+
+imply_option('--enable-network-protocols', necko_protocols,
+             reason='--enable-necko-protocols')
+
+option('--enable-network-protocols', nargs='+', default=default_necko_protocols,
+       choices=all_necko_protocols,
+       help='Enable/disable specific protocol handlers')
+
+@depends('--enable-network-protocols')
+def necko_protocol_defines(protocols):
+    return tuple('NECKO_PROTOCOL_%s' % p for p in protocols)
+
+add_old_configure_assignment('_NON_GLOBAL_ACDEFINES', necko_protocol_defines)
+
+@depends(necko_protocol_defines)
+@imports('__sandbox__')
+def set_necko_protocol_defines(protocols):
+    for p in protocols:
+        __sandbox__.set_define_impl(p, True)
+
+@depends('--enable-network-protocols')
+@imports(_from='__builtin__', _import='sorted')
+def necko_protocols(protocols):
+    return tuple(sorted(protocols))
+
+set_config('NECKO_PROTOCOLS', necko_protocols)
+add_old_configure_assignment('NECKO_PROTOCOLS', necko_protocols)