build: disable clang's unused-local-typedef warning
This commit also enables color diagnostics on release builds.
Change-Id: I75d898ac1f3cf48097850f0cda807e3bee1cd206
Refs: #3209
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 927554c..b740ed9 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,20 +95,27 @@
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',
'-Wno-error=maybe-uninitialized', # Bug #1615
- ]
+ ]
return flags
def getOptimizedFlags(self, conf):
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
- flags['CXXFLAGS'] += ['-pedantic', '-Wall', '-O2', '-g']
+ flags['CXXFLAGS'] += ['-pedantic',
+ '-Wall',
+ '-O2',
+ '-g',
+ ]
return flags
class GccFlags(GccBasicFlags):
@@ -130,23 +136,35 @@
flags = super(GccFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
'-fdiagnostics-color', # gcc >= 4.9
- ]
+ ]
+ 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',
- '-Wno-error=unneeded-internal-declaration', # Bug #1588
- '-Wno-error=deprecated-register',
- '-Wno-error=unused-local-typedef', # Bug #2657
- ]
- if Utils.unversioned_sys_platform() == "darwin":
+ flags['CXXFLAGS'] += ['-std=c++11']
+ if Utils.unversioned_sys_platform() == 'darwin':
flags['CXXFLAGS'] += ['-stdlib=libc++']
flags['LINKFLAGS'] += ['-stdlib=libc++']
return flags
def getDebugFlags(self, conf):
flags = super(ClangFlags, self).getDebugFlags(conf)
- flags['CXXFLAGS'] += ['-fcolor-diagnostics']
+ flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+ '-Wno-unused-local-typedef', # Bugs #2657 and #3209
+ '-Wno-error=unneeded-internal-declaration', # Bug #1588
+ '-Wno-error=deprecated-register',
+ ]
+ 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