diff --git a/netwerk/wifi/moz.build b/netwerk/wifi/moz.build index 1c6049d9c64c..26498f931caf 100644 --- a/netwerk/wifi/moz.build +++ b/netwerk/wifi/moz.build @@ -4,8 +4,6 @@ # 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/. -FAIL_ON_WARNINGS = True - XPIDL_SOURCES += [ 'nsIWifiAccessPoint.idl', 'nsIWifiListener.idl', @@ -27,9 +25,10 @@ else: 'nsWifiMonitor.cpp', ] +# osx_corewlan.mm has warnings I don't understand. +FAIL_ON_WARNINGS = CONFIG['OS_ARCH'] != 'Darwin' + if CONFIG['OS_ARCH'] == 'Darwin': - # osx_corewlan.mm has warnings I don't understand. - FAIL_ON_WARNINGS = False UNIFIED_SOURCES += [ 'nsWifiScannerMac.cpp', ] diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py index 979eaa2cec66..3423c32455ee 100644 --- a/python/mozbuild/mozbuild/frontend/reader.py +++ b/python/mozbuild/mozbuild/frontend/reader.py @@ -185,9 +185,9 @@ class MozbuildSandbox(Sandbox): for name, func in FUNCTIONS.items(): d[name] = getattr(self, func[0]) - # Initialize the exports that we need in the global. - extra_vars = self.metadata.get('exports', dict()) - self._globals.update(extra_vars) + # Initialize the exports that we need in the global. + extra_vars = self.metadata.get('exports', dict()) + self._globals.update(extra_vars) def exec_file(self, path, filesystem_absolute=False): """Override exec_file to normalize paths and restrict file loading. diff --git a/python/mozbuild/mozbuild/frontend/sandbox.py b/python/mozbuild/mozbuild/frontend/sandbox.py index ffdb7fd904a6..14d4748e88fc 100644 --- a/python/mozbuild/mozbuild/frontend/sandbox.py +++ b/python/mozbuild/mozbuild/frontend/sandbox.py @@ -124,6 +124,8 @@ class GlobalNamespace(dict): self._allow_all_writes = False + self._allow_one_mutation = set() + def __getitem__(self, name): try: return dict.__getitem__(self, name) @@ -151,8 +153,21 @@ class GlobalNamespace(dict): def __setitem__(self, name, value): if self._allow_all_writes: dict.__setitem__(self, name, value) + self._allow_one_mutation.add(name) return + # Forbid assigning over a previously set value. Interestingly, when + # doing FOO += ['bar'], python actually does something like: + # foo = namespace.__getitem__('FOO') + # foo.__iadd__(['bar']) + # namespace.__setitem__('FOO', foo) + # This means __setitem__ is called with the value that is already + # in the dict, when doing +=, which is permitted. + if name in self._allow_one_mutation: + self._allow_one_mutation.remove(name) + elif name in self and dict.__getitem__(self, name) is not value: + raise Exception('Reassigning %s is forbidden' % name) + # We don't need to check for name.isupper() here because LocalNamespace # only sends variables our way if isupper() is True. stored_type, input_type, docs, tier = \ @@ -195,6 +210,11 @@ class GlobalNamespace(dict): yield self self._allow_all_writes = False + # dict.update doesn't call our __setitem__, so we have to override it. + def update(self, other): + for name, value in other.items(): + self.__setitem__(name, value) + class LocalNamespace(dict): """Represents the locals namespace in a Sandbox. diff --git a/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/bar/moz.build b/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/bar/moz.build index e0755bf8f3dd..c271ec3908ce 100644 --- a/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/bar/moz.build +++ b/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/bar/moz.build @@ -3,5 +3,3 @@ # 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/. - -XPIDL_MODULE = 'bazbar' diff --git a/python/mozbuild/mozbuild/test/frontend/test_namespaces.py b/python/mozbuild/mozbuild/test/frontend/test_namespaces.py index a04fb71a45fb..b076c2060f00 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_namespaces.py +++ b/python/mozbuild/mozbuild/test/frontend/test_namespaces.py @@ -76,10 +76,23 @@ class TestGlobalNamespace(unittest.TestCase): self.assertTrue(d['foo']) with self.assertRaises(KeyError) as ke: - ns['foo'] = False + ns['bar'] = False self.assertEqual(ke.exception.args[1], 'set_unknown') + ns['DIRS'] = [] + with self.assertRaisesRegexp(Exception, 'Reassigning .* is forbidden') as ke: + ns['DIRS'] = [] + + with ns.allow_all_writes() as d: + d['DIST_SUBDIR'] = 'foo' + + self.assertEqual(ns['DIST_SUBDIR'], 'foo') + ns['DIST_SUBDIR'] = 'bar' + self.assertEqual(ns['DIST_SUBDIR'], 'bar') + with self.assertRaisesRegexp(Exception, 'Reassigning .* is forbidden') as ke: + ns['DIST_SUBDIR'] = 'baz' + self.assertTrue(d['foo']) def test_key_checking(self): diff --git a/python/mozbuild/mozbuild/test/frontend/test_reader.py b/python/mozbuild/mozbuild/test/frontend/test_reader.py index 9d2ffe66b81f..0cdcedb959f5 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_reader.py +++ b/python/mozbuild/mozbuild/test/frontend/test_reader.py @@ -262,7 +262,7 @@ class TestBuildReader(unittest.TestCase): self.assertEqual([sandbox['RELATIVEDIR'] for sandbox in sandboxes], ['', 'foo', 'foo/baz', 'bar']) self.assertEqual([sandbox['XPIDL_MODULE'] for sandbox in sandboxes], - ['foobar', 'foobar', 'foobar', 'bazbar']) + ['foobar', 'foobar', 'foobar', 'foobar']) if __name__ == '__main__': main() diff --git a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py index a1e0cd2335ae..fb83c9156ae5 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py +++ b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py @@ -146,9 +146,9 @@ class TestSandbox(unittest.TestCase): sandbox = self.sandbox() sandbox.exec_source('DIRS = ["foo"]', 'foo.py') - sandbox.exec_source('DIRS = ["bar"]', 'foo.py') + sandbox.exec_source('DIRS += ["bar"]', 'foo.py') - self.assertEqual(sandbox['DIRS'], ['bar']) + self.assertEqual(sandbox['DIRS'], ['foo', 'bar']) def test_exec_source_illegal_key_set(self): sandbox = self.sandbox() diff --git a/toolkit/components/diskspacewatcher/moz.build b/toolkit/components/diskspacewatcher/moz.build index cda367e5b85a..d5b03fba1640 100644 --- a/toolkit/components/diskspacewatcher/moz.build +++ b/toolkit/components/diskspacewatcher/moz.build @@ -13,7 +13,6 @@ EXPORTS += [ ] XPIDL_MODULE = 'diskspacewatcher' -XPIDL_MODULE = 'toolkitcomps' SOURCES = [ 'DiskSpaceWatcher.cpp',