Bug 973649 - Add logic for CFLAGS, CXXFLAGS and LDFLAGS to moz.build; r=gps
authorMs2ger <ms2ger@gmail.com>
Wed, 26 Feb 2014 12:49:00 -0800
changeset 176259 f6d3c2edbc6483b7932d781e6d4344619cbf46fa
parent 176258 3d8a39b9c13e50f1cb199849837c3ead6ea03b9e
child 176260 8423ee98bc775bc060b249ecef057bcabbec245d
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-esr52@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs973649
milestone30.0a1
Bug 973649 - Add logic for CFLAGS, CXXFLAGS and LDFLAGS to moz.build; r=gps
b2g/app/Makefile.in
b2g/app/moz.build
config/config.mk
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/frontend/sandbox_symbols.py
python/mozbuild/mozbuild/test/backend/test_recursivemake.py
python/mozbuild/mozbuild/test/frontend/test_emitter.py
toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in
toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
--- a/b2g/app/Makefile.in
+++ b/b2g/app/Makefile.in
@@ -21,17 +21,16 @@ LIBS += \
   $(MOZ_ZLIB_LIBS) \
   $(NULL)
 ifeq ($(ANDROID_VERSION),$(findstring $(ANDROID_VERSION),17 18 19))
 LIBS += \
   -lgui \
   -lsuspend \
   $(NULL)
 endif
-OS_LDFLAGS += -Wl,--export-dynamic
 endif
 
 STL_FLAGS=
 
 LIBS += $(JEMALLOC_LIBS)
 
 LIBS += \
   $(XPCOM_STANDALONE_GLUE_LDOPTS) \
--- a/b2g/app/moz.build
+++ b/b2g/app/moz.build
@@ -34,8 +34,10 @@ LOCAL_INCLUDES += [
     '/xpcom/base',
     '/xpcom/build',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     LOCAL_INCLUDES += [
         '/widget/gonk/libdisplay',
     ]
+
+    LDFLAGS += ['-Wl,--export-dynamic']
--- a/config/config.mk
+++ b/config/config.mk
@@ -476,17 +476,17 @@ INCLUDES = \
   $(NSPR_CFLAGS) $(NSS_CFLAGS) \
   $(OS_INCLUDES) \
   $(NULL)
 
 include $(topsrcdir)/config/static-checking-config.mk
 
 CFLAGS		= $(OS_CPPFLAGS) $(OS_CFLAGS)
 CXXFLAGS	= $(OS_CPPFLAGS) $(OS_CXXFLAGS)
-LDFLAGS		= $(OS_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
+LDFLAGS		= $(OS_LDFLAGS) $(MOZBUILD_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
 
 # Allow each module to override the *default* optimization settings
 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
 # arguments to --enable-optimize
 ifdef MOZ_OPTIMIZE
 ifeq (1,$(MOZ_OPTIMIZE))
 ifdef MODULE_OPTIMIZE_FLAGS
 CFLAGS		+= $(MODULE_OPTIMIZE_FLAGS)
@@ -582,20 +582,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) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(EXTRA_COMPILE_FLAGS)
-COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS) $(CXXFLAGS) $(EXTRA_COMPILE_FLAGS)
-COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(EXTRA_COMPILE_FLAGS)
-COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(EXTRA_COMPILE_FLAGS)
+COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(EXTRA_COMPILE_FLAGS)
+COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(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)
 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
@@ -237,25 +237,26 @@ class TreeMetadataEmitter(LoggingMixin):
             'LIBXUL_LIBRARY',
             'MSVC_ENABLE_PGO',
             'NO_DIST_INSTALL',
             'OS_LIBS',
             'RCFILE',
             'RESFILE',
             'DEFFILE',
             'SDK_LIBRARY',
-            'CFLAGS',
-            'CXXFLAGS',
-            'LDFLAGS',
             'WIN32_EXE_LDFLAGS',
         ]
         for v in varlist:
             if v in sandbox and sandbox[v]:
                 passthru.variables[v] = sandbox[v]
 
+        for v in ['CFLAGS', 'CXXFLAGS', 'CMFLAGS', 'CMMFLAGS', 'LDFLAGS']:
+            if v in sandbox and sandbox[v]:
+                passthru.variables['MOZBUILD_' + v] = sandbox[v]
+
         # NO_VISIBILITY_FLAGS is slightly different
         if sandbox['NO_VISIBILITY_FLAGS']:
             passthru.variables['VISIBILITY_FLAGS'] = ''
 
         if sandbox['DELAYLOAD_DLLS']:
             passthru.variables['DELAYLOAD_LDFLAGS'] = [('-DELAYLOAD:%s' % dll) for dll in sandbox['DELAYLOAD_DLLS']]
             passthru.variables['USE_DELAYIMP'] = True
 
--- a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py
+++ b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py
@@ -683,35 +683,53 @@ VARIABLES = {
     'SPHINX_PYTHON_PACKAGE_DIRS': (StrictOrderingOnAppendList, list,
         """Directories containing Python packages that Sphinx documents.
         """, None),
 
     'CFLAGS': (list, list,
         """Flags passed to the C compiler for all of the C source files
            declared in this directory.
 
-           Note that the ordering of flags matter here, these flags will be
+           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.
         """, 'binaries'),
 
     'CXXFLAGS': (list, list,
         """Flags passed to the C++ compiler for all of the C++ source files
            declared in this directory.
 
-           Note that the ordering of flags matter here, these flags will be
+           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.
+        """, 'binaries'),
+
+    'CMFLAGS': (list, list,
+        """Flags passed to the Objective-C compiler for all of the Objective-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.
+        """, 'binaries'),
+
+    'CMMFLAGS': (list, list,
+        """Flags passed to the Objective-C++ compiler for all of the
+           Objective-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.
         """, 'binaries'),
 
     'LDFLAGS': (list, list,
         """Flags passed to the linker when linking all of the libraries and
            executables declared in this directory.
 
-           Note that the ordering of flags matter here, these flags will be
+           Note that the ordering of flags matters here; these flags will be
            added to the linker's command line in the same order as they
            appear in the moz.build file.
         """, 'libs'),
 
     'WIN32_EXE_LDFLAGS': (list, list,
         """Flags passed to the linker when linking a Windows .exe executable
            declared in this directory.
 
--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
+++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
@@ -335,27 +335,27 @@ class TestRecursiveMakeBackend(BackendTe
                 'RESFILE := bar.res',
             ],
             'DEFFILE': [
                 'DEFFILE := baz.def',
             ],
             'USE_STATIC_LIBS': [
                 'USE_STATIC_LIBS := 1',
             ],
-            'CFLAGS': [
-                'CFLAGS += -fno-exceptions',
-                'CFLAGS += -w',
+            'MOZBUILD_CFLAGS': [
+                'MOZBUILD_CFLAGS += -fno-exceptions',
+                'MOZBUILD_CFLAGS += -w',
             ],
-            'CXXFLAGS': [
-                'CXXFLAGS += -fcxx-exceptions',
-                'CXXFLAGS += -include foo.h',
+            'MOZBUILD_CXXFLAGS': [
+                'MOZBUILD_CXXFLAGS += -fcxx-exceptions',
+                'MOZBUILD_CXXFLAGS += -include foo.h',
             ],
-            'LDFLAGS': [
-                'LDFLAGS += -framework Foo',
-                'LDFLAGS += -x',
+            'MOZBUILD_LDFLAGS': [
+                'MOZBUILD_LDFLAGS += -framework Foo',
+                'MOZBUILD_LDFLAGS += -x',
             ],
             'WIN32_EXE_LDFLAGS': [
                 'WIN32_EXE_LDFLAGS += -subsystem:console',
             ],
         }
 
         for var, val in expected.items():
             # print("test_variable_passthru[%s]" % (var))
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -171,19 +171,19 @@ class TestEmitterBasic(unittest.TestCase
             SSRCS=['bans.S', 'fans.S'],
             VISIBILITY_FLAGS='',
             DELAYLOAD_LDFLAGS=['-DELAYLOAD:foo.dll', '-DELAYLOAD:bar.dll'],
             USE_DELAYIMP=True,
             RCFILE='foo.rc',
             RESFILE='bar.res',
             DEFFILE='baz.def',
             USE_STATIC_LIBS=True,
-            CFLAGS=['-fno-exceptions', '-w'],
-            CXXFLAGS=['-fcxx-exceptions', '-include foo.h'],
-            LDFLAGS=['-framework Foo', '-x'],
+            MOZBUILD_CFLAGS=['-fno-exceptions', '-w'],
+            MOZBUILD_CXXFLAGS=['-fcxx-exceptions', '-include foo.h'],
+            MOZBUILD_LDFLAGS=['-framework Foo', '-x'],
             WIN32_EXE_LDFLAGS=['-subsystem:console'],
         )
 
         variables = objs[0].variables
         maxDiff = self.maxDiff
         self.maxDiff = None
         self.assertEqual(wanted, variables)
         self.maxDiff = maxDiff
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in
+++ /dev/null
@@ -1,7 +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/.
-
-include $(topsrcdir)/config/rules.mk
-
-COMPILE_CMFLAGS += -std=c99
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
@@ -33,8 +33,9 @@ SOURCES += [
 LIBRARY_NAME = 'breakpad_mac_common_s'
 
 FINAL_LIBRARY = 'xulapp_s'
 
 LOCAL_INCLUDES += [
     '../..',
 ]
 
+CMFLAGS += ['-std=c99']