Bug 1235738 - Move MOZ_DEBUG_DEFINES to build frontend. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 29 Dec 2015 16:00:21 +0900
changeset 278040 3a68ebf32f839b03c99708ed136045bfbf0d020a
parent 278039 4d454d2bb20e9a5be8cae2115a16c2fbdb410888
child 278041 51b8dcf42ee00572dd45e10444f023a1468d92ad
push id29841
push userryanvm@gmail.com
push dateSat, 02 Jan 2016 00:29:52 +0000
treeherdermozilla-central@f7fbc524f9f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1235738
milestone46.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 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
config/config.mk
config/faster/rules.mk
config/rules.mk
gfx/harfbuzz/src/Makefile.in
gfx/harfbuzz/src/moz.build
memory/replace/logalloc/Makefile.in
memory/replace/logalloc/moz.build
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/data.py
--- a/b2g/locales/Makefile.in
+++ b/b2g/locales/Makefile.in
@@ -52,17 +52,17 @@ include $(topsrcdir)/toolkit/locales/l10
 
 $(STAGEDIST): $(DIST)/branding
 
 $(DIST)/branding:
 	$(NSINSTALL) -D $@
 
 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
 
 NO_JA_JP_MAC_AB_CD := $(if $(filter ja-JP-mac, $(AB_CD)),ja,$(AB_CD))
 
 libs-%:
 	$(NSINSTALL) -D $(DIST)/install
 	@$(MAKE) -C ../../toolkit/locales libs-$*
--- a/config/config.mk
+++ b/config/config.mk
@@ -154,18 +154,16 @@ TOUCH ?= touch
 
 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
 
 # determine debug-related options
 _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_)
       _DEBUG_ASFLAGS += -g cv8
     else
       ifneq ($(OS_ARCH),Darwin)
         _DEBUG_ASFLAGS += -g dwarf2
       endif
--- a/config/faster/rules.mk
+++ b/config/faster/rules.mk
@@ -102,17 +102,16 @@ ACDEFINES += -DBUILD_FASTER
 	@# support for defines tracking in process_install_manifest.
 	@touch install_$(subst /,_,$*)
 	$(PYTHON) -m mozbuild.action.process_install_manifest \
 		--track install_$(subst /,_,$*).track \
 		$(TOPOBJDIR)/$* \
 		-DAB_CD=en-US \
 		-DMOZ_APP_BUILDID=$(shell cat $(TOPOBJDIR)/config/buildid) \
 		$(ACDEFINES) \
-		$(MOZ_DEBUG_DEFINES) \
 		install_$(subst /,_,$*)
 
 # ============================================================================
 # Below is a set of additional dependencies and variables used to build things
 # that are not supported by data in moz.build.
 
 # Files to build with the recursive backend and simply copy
 $(TOPOBJDIR)/dist/bin/platform.ini: $(TOPOBJDIR)/toolkit/xre/platform.ini
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1212,17 +1212,17 @@ ifndef XPI_ROOT_APPID
 $(error XPI_ROOT_APPID is not defined - langpacks will break.)
 endif
 endif
 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
 
 # This is a temporary check to ensure patches relying on the old behavior
 # of silently picking up jar.mn files continue to work.
 else # No JAR_MANIFEST
 ifneq (,$(wildcard $(srcdir)/jar.mn))
@@ -1454,17 +1454,17 @@ pp_target_results = $(foreach file,$($(1
 $(foreach tier,$(PP_TARGETS_TIERS), \
   $(eval $(tier):: $(PP_TARGETS_RESULTS_$(tier))) \
 )
 
 PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS_RESULTS_$(tier))))
 $(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 %
 
 # The depfile is based on the filename, and we don't want conflicts. So check
 # there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
 PP_TARGETS_ALL_RESULT_NAMES := $(notdir $(PP_TARGETS_ALL_RESULTS))
 $(foreach file,$(sort $(PP_TARGETS_ALL_RESULT_NAMES)), \
   $(if $(filter-out 1,$(words $(filter $(file),$(PP_TARGETS_ALL_RESULT_NAMES)))), \
deleted file mode 100644
--- 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
--- a/gfx/harfbuzz/src/moz.build
+++ b/gfx/harfbuzz/src/moz.build
@@ -64,8 +64,11 @@ ALLOW_COMPILER_WARNINGS = True
 
 FINAL_LIBRARY = 'gkmedias'
 
 DEFINES['PACKAGE_VERSION'] = '"moz"'
 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
deleted file mode 100644
--- 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=
--- a/memory/replace/logalloc/moz.build
+++ b/memory/replace/logalloc/moz.build
@@ -11,16 +11,17 @@ SOURCES += [
     'LogAlloc.cpp',
 ]
 
 DISABLE_STL_WRAPPING = True
 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':
     SOURCES += [
         '../../../ipc/chromium/src/base/lock_impl_win.cc',
     ]
 else:
     SOURCES += [
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -451,16 +451,19 @@ class RecursiveMakeBackend(CommonBackend
 
         elif isinstance(obj, TestManifest):
             self._process_test_manifest(obj, backend_file)
 
         # If CommonBackend acknowledged the object, we're done with it.
         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):
             # Other ConfigFileSubstitution should have been acked by
             # CommonBackend.
             assert os.path.basename(obj.output_path) == 'Makefile'
             self._create_makefile(obj)
         elif isinstance(obj, (Sources, GeneratedSources)):
@@ -919,20 +922,18 @@ class RecursiveMakeBackend(CommonBackend
 
         for tier in set(self._no_skip.keys()) & affected_tiers:
             self._no_skip[tier].add(backend_file.relobjdir)
 
     def _process_defines(self, obj, backend_file, which='DEFINES'):
         """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():
             for source in files:
                 dest = '%s/%s' % (path, mozpath.basename(source))
                 self._install_manifests['_tests'].add_symlink(source, dest)
 
         for path, patterns in obj.srcdir_pattern_files.iteritems():
@@ -1444,17 +1445,17 @@ INSTALL_TARGETS += %(prefix)s
             rule = mk.create_rule([basename])
             rule.add_dependencies([source, '$(GLOBAL_DEPS)'])
             rule.add_commands([
                 # Remove the file before writing so bindings that go from
                 # static to preprocessed don't end up writing to a symlink,
                 # 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,
             unified_source_mapping,
             unified_files_makefile_variable='unified_binding_cpp_files')
 
         webidls_mk = mozpath.join(bindings_dir, 'webidlsrcs.mk')
         with self._write_file(webidls_mk) as fh:
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -276,16 +276,29 @@ class SubContext(Context, ContextDerived
             raise Exception('a sandbox is required')
 
         self._sandbox().push_subcontext(self)
 
     def __exit__(self, exc_type, exc_value, traceback):
         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:
             value = 'dist/'
             if context['XPI_NAME']:
                 value += 'xpi-stage/' + context['XPI_NAME']
             else:
                 value += 'bin'
@@ -952,17 +965,17 @@ VARIABLES = {
           GENERATED_FILES += ['bar.c']
           bar = GENERATED_FILES['bar.c']
           bar.script = 'generate.py:make_bar'
 
         The chosen script entry point may optionally return a set of strings,
         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
         values, ``-Dkey=value`` for numeric values, or ``-Dkey`` if the
         value is True. Note that for string values, the outer-level of
         single-quotes will be consumed by the shell. If you want to have
         a string-literal in the program, the value needs to have
         double-quotes.
@@ -1593,17 +1606,17 @@ VARIABLES = {
         """Flags passed to the C++ compiler for all of the C++ source files
            declared in this directory.
 
            Note that the ordering of flags matters here; these flags will be
            added to the compiler's command line in the same order as they
            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),
 
     'CMFLAGS': (List, list,
         """Flags passed to the Objective-C compiler for all of the Objective-C
            source files declared in this directory.
 
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -74,28 +74,28 @@ class ContextDerived(TreeMetadata):
         self._context = context
 
     @property
     def install_target(self):
         return self._context['FINAL_TARGET']
 
     @property
     def defines(self):
-        defines = self._context.get('DEFINES')
+        defines = self._context['DEFINES']
         return Defines(self._context, defines) if defines else None
 
     @property
     def relobjdir(self):
         return mozpath.relpath(self.objdir, self.topobjdir)
 
 
 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
 
 
 class DirectoryTraversal(ContextDerived):
     """Describes how directory traversal for building should work.
 
     This build object is likely only of interest to the recursive make backend.
     Other build backends should (ideally) not attempt to mimic the behavior of