Bug 1162852 - Remove EXTRA_COMPILE_FLAGS. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 08 May 2015 14:04:15 +0900
changeset 243440 6b852bac05061cf891030c67e24f7016feb268a6
parent 243439 a48557804303bd3ea59830d5dee4a98f56bef995
child 243441 f51c116920fc2ed01efa252bf6284a64648d7aba
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherdermozilla-central@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1162852
milestone40.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 1162852 - Remove EXTRA_COMPILE_FLAGS. r=gps We now have corresponding variables in moz.build contexts that can be used instead.
config/config.mk
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/frontend/gyp_reader.py
--- a/config/config.mk
+++ b/config/config.mk
@@ -426,20 +426,20 @@ HOST_CMMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 endif
 endif
 
-COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(EXTRA_COMPILE_FLAGS)
-COMPILE_CXXFLAGS = $(if $(DISABLE_STL_WRAPPING),,$(STL_FLAGS)) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(EXTRA_COMPILE_FLAGS)
-COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS) $(EXTRA_COMPILE_FLAGS)
-COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS) $(EXTRA_COMPILE_FLAGS)
+COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS)
+COMPILE_CXXFLAGS = $(if $(DISABLE_STL_WRAPPING),,$(STL_FLAGS)) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS)
+COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS)
+COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS)
 ASFLAGS += $(MOZBUILD_ASFLAGS) $(EXTRA_ASSEMBLER_FLAGS)
 
 ifndef CROSS_COMPILE
 HOST_CFLAGS += $(RTL_FLAGS)
 endif
 
 #
 # Name of the binary code directories
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -550,17 +550,16 @@ class TreeMetadataEmitter(LoggingMixin):
         # them. We should aim to keep this set small because it violates the
         # desired abstraction of the build definition away from makefiles.
         passthru = VariablePassthru(context)
         varlist = [
             'ANDROID_GENERATED_RESFILES',
             'ANDROID_RES_DIRS',
             'DISABLE_STL_WRAPPING',
             'EXTRA_ASSEMBLER_FLAGS',
-            'EXTRA_COMPILE_FLAGS',
             'EXTRA_COMPONENTS',
             'EXTRA_DSO_LDOPTS',
             'EXTRA_PP_COMPONENTS',
             'FAIL_ON_WARNINGS',
             'USE_STATIC_LIBS',
             'NO_DIST_INSTALL',
             'PYTHON_UNIT_TESTS',
             'RCFILE',
--- a/python/mozbuild/mozbuild/frontend/gyp_reader.py
+++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py
@@ -2,16 +2,17 @@
 # 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/.
 
 from __future__ import unicode_literals
 import gyp
 import sys
 import time
 import os
+from itertools import chain
 import mozpack.path as mozpath
 from mozpack.files import FileFinder
 from .sandbox import alphabetical_sorted
 from .context import (
     TemplateContext,
     VARIABLES,
 )
 from mozbuild.util import (
@@ -67,17 +68,16 @@ class GypContext(TemplateContext):
     @classmethod
     @memoize
     def VARIABLES(cls):
         """Returns the allowed variables for a GypContext."""
         # Using a class method instead of a class variable to hide the content
         # from sphinx.
         return dict(VARIABLES,
         EXTRA_ASSEMBLER_FLAGS=(List, list, '', None),
-        EXTRA_COMPILE_FLAGS=(List, list, '', None),
     )
 
 
 def encode(value):
     if isinstance(value, unicode):
         return value.encode('utf-8')
     return value
 
@@ -199,17 +199,35 @@ def read_from_gyp(config, path, output, 
                     resolved = mozpath.abspath(mozpath.join(config.topsrcdir, include[1:]))
                 else:
                     resolved = mozpath.abspath(mozpath.join(mozpath.dirname(build_file), include))
                 if not os.path.exists(resolved):
                     continue
                 context['LOCAL_INCLUDES'] += [include]
 
             context['EXTRA_ASSEMBLER_FLAGS'] = target_conf.get('asflags_mozilla', [])
-            context['EXTRA_COMPILE_FLAGS'] = target_conf.get('cflags_mozilla', [])
+            flags = target_conf.get('cflags_mozilla', [])
+            if flags:
+                suffix_map = {
+                    '.c': 'CFLAGS',
+                    '.cpp': 'CXXFLAGS',
+                    '.cc': 'CXXFLAGS',
+                    '.m': 'CMFLAGS',
+                    '.mm': 'CMMFLAGS',
+                }
+                extensions = {
+                    mozpath.splitext(f)[-1]
+                    for f in chain(sources, unified_sources)
+                }
+                variables = (
+                    suffix_map[e]
+                    for e in extensions if e in suffix_map
+                )
+                for var in variables:
+                    context[var].extend(flags)
         else:
             # Ignore other types than static_library because we don't have
             # anything using them, and we're not testing them. They can be
             # added when that becomes necessary.
             raise NotImplementedError('Unsupported gyp target type: %s' % spec['type'])
 
         # Add some features to all contexts. Put here in case LOCAL_INCLUDES
         # order matters.