build: disable clang's unused-local-typedef warning
This commit also enables color diagnostics on release builds.
Change-Id: Ifcdadba1bc31ce64779007e7b33f8d2fee5b04b6
Refs: #3209
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index d2bc218..35907b9 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -14,22 +14,21 @@
flags = ClangFlags()
else:
flags = CompilerFlags()
- Logs.warn('The code has not been yet tested with %s compiler' % cxx)
+ Logs.warn('The code has not yet been tested with %s compiler' % cxx)
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
- # General flags will alway be applied (e.g., selecting C++11 mode)
+ # General flags are always applied (e.g., selecting C++11 mode)
generalFlags = flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
conf.env.DEFINES += generalFlags['DEFINES']
- # Debug or optimization CXXFLAGS and LINKFLAGS will be applied only if the
+ # Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
# corresponding environment variables are not set.
- # DEFINES will be always applied
+ # DEFINES are always applied.
if conf.options.debug:
extraFlags = flags.getDebugFlags(conf)
-
if areCustomCxxflagsPresent:
missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
@@ -96,10 +95,13 @@
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
class GccBasicFlags(CompilerFlags):
- """This class defines base flags that work for gcc and clang compiler"""
+ """
+ This class defines basic flags that work for both gcc and clang compilers
+ """
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
- flags['CXXFLAGS'] += ['-pedantic', '-Wall',
+ flags['CXXFLAGS'] += ['-pedantic',
+ '-Wall',
'-O0',
'-g3',
'-Werror',
@@ -109,7 +111,8 @@
def getOptimizedFlags(self, conf):
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
- flags['CXXFLAGS'] += ['-pedantic', '-Wall',
+ flags['CXXFLAGS'] += ['-pedantic',
+ '-Wall',
'-O2',
'-g',
]
@@ -138,11 +141,16 @@
]
return flags
+ def getOptimizedFlags(self, conf):
+ flags = super(GccFlags, self).getOptimizedFlags(conf)
+ flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
+ return flags
+
class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
flags['CXXFLAGS'] += ['-std=c++11']
- if Utils.unversioned_sys_platform() == "darwin":
+ if Utils.unversioned_sys_platform() == 'darwin':
flags['CXXFLAGS'] += ['-stdlib=libc++']
flags['LINKFLAGS'] += ['-stdlib=libc++']
return flags
@@ -150,8 +158,15 @@
def getDebugFlags(self, conf):
flags = super(ClangFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+ '-Wno-unused-local-typedef', # Bugs #2657 and #3209
'-Wno-error=unneeded-internal-declaration', # Bug #1588
'-Wno-error=deprecated-register',
- '-Wno-error=unused-local-typedef', # Bug #2657
+ ]
+ return flags
+
+ def getOptimizedFlags(self, conf):
+ flags = super(ClangFlags, self).getOptimizedFlags(conf)
+ flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+ '-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
return flags