Bug 1384241 - Pre: Extract acdefines() helper function. r=gps draft
authorNick Alexander <nalexander@mozilla.com>
Wed, 26 Jul 2017 19:31:18 -0700
changeset 617789 de26dd98836ec49d0abc93052e84b6a90b3e248f
parent 617496 16ffc1d05422a81099ce8b9b59de66dde4c8b2f0
child 617790 154604ec231875a355b2b5686644c9fbe6bab120
child 617908 13dbeac2fbfa78741be3718fd5305a8ae0d698a8
push id71133
push usernalexander@mozilla.com
push dateFri, 28 Jul 2017 21:56:58 +0000
reviewersgps
bugs1384241
milestone56.0a1
Bug 1384241 - Pre: Extract acdefines() helper function. r=gps MozReview-Commit-ID: 6TstvuluvH3
python/mozbuild/mozbuild/backend/configenvironment.py
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/configenvironment.py
+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
@@ -7,17 +7,20 @@ from __future__ import absolute_import
 import os
 import sys
 
 from collections import Iterable
 from types import StringTypes, ModuleType
 
 import mozpack.path as mozpath
 
-from mozbuild.util import ReadOnlyDict
+from mozbuild.util import (
+    memoized_property,
+    ReadOnlyDict,
+)
 from mozbuild.shellutil import quote as shell_quote
 
 
 if sys.version_info.major == 2:
     text_type = unicode
 else:
     text_type = str
 
@@ -189,14 +192,21 @@ class ConfigEnvironment(object):
             self.substs_unicode[k] = v
 
         self.substs_unicode = ReadOnlyDict(self.substs_unicode)
 
     @property
     def is_artifact_build(self):
         return self.substs.get('MOZ_ARTIFACT_BUILDS', False)
 
+    @memoized_property
+    def acdefines(self):
+        acdefines = dict((name, self.defines[name])
+                         for name in self.defines
+                         if name not in self.non_global_defines)
+        return ReadOnlyDict(acdefines)
+
     @staticmethod
     def from_config_status(path):
         config = BuildConfig.from_config_status(path)
 
         return ConfigEnvironment(config.topsrcdir, config.topobjdir,
             config.defines, config.non_global_defines, config.substs, path)
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -231,21 +231,18 @@ class TupOnly(CommonBackend, PartialBack
 
         for objdir, backend_file in sorted(self._backend_files.items()):
             for obj in backend_file.delayed_generated_files:
                 self._process_generated_file(backend_file, obj)
             with self._write_file(fh=backend_file):
                 pass
 
         with self._write_file(mozpath.join(self.environment.topobjdir, 'Tuprules.tup')) as fh:
-            acdefines = [name for name in self.environment.defines
-                if not name in self.environment.non_global_defines]
-            acdefines_flags = ' '.join(['-D%s=%s' % (name,
-                shell_quote(self.environment.defines[name]))
-                for name in sorted(acdefines)])
+            acdefines_flags = ' '.join(['-D%s=%s' % (name, shell_quote(value))
+                for (name, value) in sorted(self.environment.acdefines.iteritems())])
             # TODO: AB_CD only exists in Makefiles at the moment.
             acdefines_flags += ' -DAB_CD=en-US'
 
             # TODO: BOOKMARKS_INCLUDE_DIR is used by bookmarks.html.in, and is
             # only defined in browser/locales/Makefile.in
             acdefines_flags += ' -DBOOKMARKS_INCLUDE_DIR=%s/browser/locales/en-US/profile' % self.environment.topsrcdir
 
             # Use BUILD_FASTER to avoid CXXFLAGS/CPPFLAGS in