From e0c501a1c124795bfe1d180ba63bc23752422ece Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 29 Dec 2015 16:00:21 +0900 Subject: [PATCH] Bug 1235738 - Move MOZ_DEBUG_DEFINES to build frontend. r=gps MOZ_DEBUG_DEFINES are essentially defines used everywhere. So treat them as feeding the initial value for DEFINES in each moz.build sandbox. This allows the kind overrides that was done in the past by resetting MOZ_DEBUG_DEFINES in Makefiles. --- b2g/locales/Makefile.in | 2 +- config/config.mk | 2 -- config/faster/rules.mk | 1 - config/rules.mk | 4 +-- gfx/harfbuzz/src/Makefile.in | 31 ------------------- gfx/harfbuzz/src/moz.build | 3 ++ memory/replace/logalloc/Makefile.in | 6 ---- memory/replace/logalloc/moz.build | 1 + .../mozbuild/backend/recursivemake.py | 11 ++++--- python/mozbuild/mozbuild/frontend/context.py | 17 ++++++++-- python/mozbuild/mozbuild/frontend/data.py | 4 +-- 11 files changed, 30 insertions(+), 52 deletions(-) delete mode 100644 gfx/harfbuzz/src/Makefile.in delete mode 100644 memory/replace/logalloc/Makefile.in diff --git a/b2g/locales/Makefile.in b/b2g/locales/Makefile.in index dd8df0382805..bed33811271f 100644 --- a/b2g/locales/Makefile.in +++ b/b2g/locales/Makefile.in @@ -57,7 +57,7 @@ $(DIST)/branding: libs:: @if test -f '$(LOCALE_SRCDIR)/existing-profile-defaults.js'; then \ - $(PYTHON) -m mozbuild.action.preprocessor $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(MOZ_DEBUG_DEFINES) \ + $(PYTHON) -m mozbuild.action.preprocessor $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) \ $(LOCALE_SRCDIR)/existing-profile-defaults.js -o $(FINAL_TARGET)/defaults/existing-profile-defaults.js; \ fi diff --git a/config/config.mk b/config/config.mk index d0de93df2b06..f195a15941de 100644 --- a/config/config.mk +++ b/config/config.mk @@ -159,8 +159,6 @@ _DEBUG_ASFLAGS := _DEBUG_CFLAGS := _DEBUG_LDFLAGS := -_DEBUG_CFLAGS += $(MOZ_DEBUG_DEFINES) - ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS)) ifeq ($(AS),yasm) ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) diff --git a/config/faster/rules.mk b/config/faster/rules.mk index 17f5494b6f98..29d64d5e6835 100644 --- a/config/faster/rules.mk +++ b/config/faster/rules.mk @@ -107,7 +107,6 @@ $(addprefix install-,$(INSTALL_MANIFESTS)): install-%: $(TOPOBJDIR)/config/build -DAB_CD=en-US \ -DMOZ_APP_BUILDID=$(shell cat $(TOPOBJDIR)/config/buildid) \ $(ACDEFINES) \ - $(MOZ_DEBUG_DEFINES) \ install_$(subst /,_,$*) # ============================================================================ diff --git a/config/rules.mk b/config/rules.mk index c981dcf43e51..d4c70af6c130 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -1217,7 +1217,7 @@ endif libs realchrome:: $(FINAL_TARGET)/chrome $(call py_action,jar_maker,\ $(QUIET) -d $(FINAL_TARGET) \ - $(MAKE_JARS_FLAGS) $(DEFINES) $(ACDEFINES) $(MOZ_DEBUG_DEFINES) \ + $(MAKE_JARS_FLAGS) $(DEFINES) $(ACDEFINES) \ $(JAR_MANIFEST)) endif @@ -1459,7 +1459,7 @@ PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS $(PP_TARGETS_ALL_RESULTS): $(if $(filter-out $(notdir $@),$(notdir $(<:.in=))),$(error Looks like $@ has an unexpected dependency on $< which breaks PP_TARGETS)) $(RM) '$@' - $(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) $(MOZ_DEBUG_DEFINES) '$<' -o '$@') + $(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) '$<' -o '$@') $(filter %.css,$(PP_TARGETS_ALL_RESULTS)): PP_TARGET_FLAGS+=--marker % diff --git a/gfx/harfbuzz/src/Makefile.in b/gfx/harfbuzz/src/Makefile.in deleted file mode 100644 index b28584491f44..000000000000 --- a/gfx/harfbuzz/src/Makefile.in +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (C) 2010 Mozilla Foundation -# -# This is used to integrate the HarfBuzz library with the Mozilla build. -# -# Permission is hereby granted, without written agreement and without -# license or royalty fees, to use, copy, modify, and distribute this -# software and its documentation for any purpose, provided that the -# above copyright notice and the following two paragraphs appear in -# all copies of this software. -# -# IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR -# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES -# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN -# IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGE. -# -# THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, -# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -# ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO -# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -# -# Mozilla author(s): Jonathan Kew -# - -include $(topsrcdir)/config/rules.mk - -# Cancel the effect of the -DDEBUG macro if present, -# because harfbuzz uses that name for its own purposes -COMPILE_CXXFLAGS += -UDEBUG diff --git a/gfx/harfbuzz/src/moz.build b/gfx/harfbuzz/src/moz.build index 51dfc705c125..86bbb2b56f6c 100644 --- a/gfx/harfbuzz/src/moz.build +++ b/gfx/harfbuzz/src/moz.build @@ -69,3 +69,6 @@ DEFINES['PACKAGE_BUGREPORT'] = '"http://bugzilla.mozilla.org/"' DEFINES['HAVE_OT'] = 1 DEFINES['HB_NO_MT'] = True DEFINES['HB_NO_UNICODE_FUNCS'] = True +# Cancel the effect of the -DDEBUG macro if present, +# because harfbuzz uses that name for its own purposes +DEFINES['DEBUG'] = False diff --git a/memory/replace/logalloc/Makefile.in b/memory/replace/logalloc/Makefile.in deleted file mode 100644 index b0fe8129e475..000000000000 --- a/memory/replace/logalloc/Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -# 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/. - -# Avoid Lock_impl code depending on mozilla::Logger -MOZ_DEBUG_DEFINES= diff --git a/memory/replace/logalloc/moz.build b/memory/replace/logalloc/moz.build index 9deb355131e2..12bf6eb15b5d 100644 --- a/memory/replace/logalloc/moz.build +++ b/memory/replace/logalloc/moz.build @@ -16,6 +16,7 @@ USE_STATIC_LIBS = True DEFINES['MOZ_NO_MOZALLOC'] = True # Avoid Lock_impl code depending on mozilla::Logger. DEFINES['NDEBUG'] = True +DEFINES['DEBUG'] = False # Use locking code from the chromium stack. if CONFIG['OS_TARGET'] == 'WINNT': diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 6daf26a4eb76..3174adb237be 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -456,6 +456,9 @@ class RecursiveMakeBackend(CommonBackend): if consumed: return True + if not isinstance(obj, Defines): + self.consume_object(obj.defines) + if isinstance(obj, DirectoryTraversal): self._process_directory_traversal(obj, backend_file) elif isinstance(obj, ConfigFileSubstitution): @@ -924,10 +927,8 @@ class RecursiveMakeBackend(CommonBackend): """Output the DEFINES rules to the given backend file.""" defines = list(obj.get_defines()) if defines: - backend_file.write(which + ' +=') - for define in defines: - backend_file.write(' %s' % define) - backend_file.write('\n') + defines = ' '.join(defines) + backend_file.write_once('%s += %s\n' % (which, defines)) def _process_test_harness_files(self, obj, backend_file): for path, files in obj.srcdir_files.iteritems(): @@ -1449,7 +1450,7 @@ INSTALL_TARGETS += %(prefix)s # which would modify content in the source directory. '$(RM) $@', '$(call py_action,preprocessor,$(DEFINES) $(ACDEFINES) ' - '$(MOZ_DEBUG_DEFINES) $< -o $@)' + '$< -o $@)' ]) self._add_unified_build_rules(mk, diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index ce7b72d0fd8c..b1ef360408ae 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -281,6 +281,19 @@ class SubContext(Context, ContextDerivedValue): self._sandbox().pop_subcontext(self) +class InitializedDefines(ContextDerivedValue, OrderedDict): + def __init__(self, context, value=None): + OrderedDict.__init__(self) + for define in context.config.substs.get('MOZ_DEBUG_DEFINES', '').split(): + assert define[:2] == "-D" + pair = define[2:].split('=', 1) + if len(pair) == 1: + pair.append(1) + self[pair[0]] = pair[1] + if value: + self.update(value) + + class FinalTargetValue(ContextDerivedValue, unicode): def __new__(cls, context, value=""): if not value: @@ -957,7 +970,7 @@ VARIABLES = { indicating extra files the output depends on. """, 'export'), - 'DEFINES': (OrderedDict, dict, + 'DEFINES': (InitializedDefines, dict, """Dictionary of compiler defines to declare. These are passed in to the compiler as ``-Dkey='value'`` for string @@ -1598,7 +1611,7 @@ VARIABLES = { appear in the moz.build file. """, None), - 'HOST_DEFINES': (OrderedDict, dict, + 'HOST_DEFINES': (InitializedDefines, dict, """Dictionary of compiler defines to declare for host compilation. See ``DEFINES`` for specifics. """, None), diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 9aabf4fca18c..7270645bbbb7 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -79,7 +79,7 @@ class ContextDerived(TreeMetadata): @property def defines(self): - defines = self._context.get('DEFINES') + defines = self._context['DEFINES'] return Defines(self._context, defines) if defines else None @property @@ -90,7 +90,7 @@ class ContextDerived(TreeMetadata): class HostMixin(object): @property def defines(self): - defines = self._context.get('HOST_DEFINES') + defines = self._context['HOST_DEFINES'] return HostDefines(self._context, defines) if defines else None