Bug 1229241 - Allow moz.build special variables to be set, as long as the value is not modified. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 27 Nov 2015 21:01:28 +0900
changeset 308990 b69aaa0c37118c43a5830c721fb40854a3f5c1cc
parent 308989 e03b93cbb64d4996a9f170d76a69801b9a708d84
child 308991 7b183b8a6116a5f5d65eeccbab97ced59910ef79
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1229241
milestone45.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 1229241 - Allow moz.build special variables to be set, as long as the value is not modified. r=gps This will allow a new kind of special variable where it is possible to do FOO += ['bar'] All the current special variables are either strings (for which __setitem__ would be called with a different string object), or a read-only dict (which doesn't allow modifications).
python/mozbuild/mozbuild/frontend/reader.py
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -214,16 +214,18 @@ class MozbuildSandbox(Sandbox):
     def __contains__(self, key):
         if any(key in d for d in (self.special_variables, self.functions,
                                   self.subcontext_types, self.templates)):
             return True
 
         return Sandbox.__contains__(self, key)
 
     def __setitem__(self, key, value):
+        if key in self.special_variables and value is self[key]:
+            return
         if key in self.special_variables or key in self.functions or key in self.subcontext_types:
             raise KeyError('Cannot set "%s" because it is a reserved keyword'
                            % key)
         if key in self.exports:
             self._context[key] = value
             self.exports.remove(key)
             return
         Sandbox.__setitem__(self, key, value)