Bug 1384241 - Pre: Extract acdefines() helper function. r=gps
MozReview-Commit-ID: 6TstvuluvH3
--- 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