build+ci: enable code-coverage reporting
This required changing the CI scripts to run the
unit tests against the debug version of NLSR.
Also sync default-compiler-flags.py with NFD.
Change-Id: I31f37e3dfef2c1237393512e0c238f5e6bcbe525
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 7544cec..e11f7f1 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -4,17 +4,37 @@
def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
- help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
+ help='''Compile in debugging mode with minimal optimizations (-O0 or -Og)''')
def configure(conf):
- cxx = conf.env['CXX_NAME'] # CXX_NAME represents generic name of the compiler
+ conf.start_msg('Checking C++ compiler version')
+
+ cxx = conf.env['CXX_NAME'] # CXX_NAME is the generic name of the compiler
+ ccver = tuple(int(i) for i in conf.env['CC_VERSION'])
+ errmsg = ''
+ warnmsg = ''
if cxx == 'gcc':
+ if ccver < (4, 8, 2):
+ errmsg = ('The version of gcc you are using is too old.\n'
+ 'The minimum supported gcc version is 4.8.2.')
flags = GccFlags()
elif cxx == 'clang':
+ if ccver < (3, 4, 0):
+ errmsg = ('The version of clang you are using is too old.\n'
+ 'The minimum supported clang version is 3.4.0.')
flags = ClangFlags()
else:
+ warnmsg = 'Note: %s compiler is unsupported' % cxx
flags = CompilerFlags()
- Logs.warn('The code has not yet been tested with %s compiler' % cxx)
+
+ if errmsg:
+ conf.end_msg('.'.join(conf.env['CC_VERSION']), color='RED')
+ conf.fatal(errmsg)
+ elif warnmsg:
+ conf.end_msg('.'.join(conf.env['CC_VERSION']), color='YELLOW')
+ Logs.warn(warnmsg)
+ else:
+ conf.end_msg('.'.join(conf.env['CC_VERSION']))
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
@@ -80,6 +100,7 @@
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('LINKFLAGS', supportedFlags)
+
class CompilerFlags(object):
def getGeneralFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
@@ -97,18 +118,25 @@
"""
This class defines basic flags that work for both gcc and clang compilers
"""
+ def getGeneralFlags(self, conf):
+ flags = super(GccBasicFlags, self).getGeneralFlags(conf)
+ flags['CXXFLAGS'] += ['-std=c++11']
+ return flags
+
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-O0',
+ '-Og', # gcc >= 4.8, clang >= 4.0
'-g3',
'-pedantic',
'-Wall',
'-Wextra',
'-Werror',
- '-Wno-unused-parameter',
- '-Wno-error=maybe-uninitialized', # Bug #1615
'-Wno-error=deprecated-declarations', # Bug #3795
+ '-Wno-error=maybe-uninitialized', # Bug #1615
+ '-Wno-unused-parameter',
]
+ flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
return flags
def getOptimizedFlags(self, conf):
@@ -120,32 +148,16 @@
'-Wextra',
'-Wno-unused-parameter',
]
+ flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
return flags
class GccFlags(GccBasicFlags):
- def getGeneralFlags(self, conf):
- flags = super(GccFlags, self).getGeneralFlags(conf)
- version = tuple(int(i) for i in conf.env['CC_VERSION'])
- if version < (4, 6, 0):
- conf.fatal('The version of gcc you are using (%s) is too old.\n' %
- '.'.join(conf.env['CC_VERSION']) +
- 'The minimum supported gcc version is 4.6.0.')
- elif version < (4, 7, 0):
- flags['CXXFLAGS'] += ['-std=c++0x']
- else:
- flags['CXXFLAGS'] += ['-std=c++11']
- if version < (4, 8, 0):
- flags['DEFINES'] += ['_GLIBCXX_USE_NANOSLEEP'] # Bug #2499
- return flags
-
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
version = tuple(int(i) for i in conf.env['CC_VERSION'])
if version < (5, 1, 0):
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
- flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
- '-fdiagnostics-color', # gcc >= 4.9
- ]
+ flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
return flags
def getOptimizedFlags(self, conf):
@@ -159,7 +171,6 @@
class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
- flags['CXXFLAGS'] += ['-std=c++11']
if Utils.unversioned_sys_platform() == 'darwin':
flags['CXXFLAGS'] += ['-stdlib=libc++']
flags['LINKFLAGS'] += ['-stdlib=libc++']
@@ -168,24 +179,24 @@
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=ignored-qualifiers',
+ '-Wno-error=infinite-recursion', # Bug #3358
'-Wno-error=keyword-macro', # Bug #3235
+ '-Wno-error=unneeded-internal-declaration', # Bug #1588
+ '-Wno-keyword-macro',
'-Wno-nested-anon-types',
'-Wno-sign-compare',
- '-Wno-keyword-macro',
- '-Wno-error=ignored-qualifiers',
- '-Wno-error=infinite-recursion',
+ '-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
return flags
def getOptimizedFlags(self, conf):
flags = super(ClangFlags, self).getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
- '-Wno-unused-local-typedef', # Bugs #2657 and #3209
+ '-Wno-keyword-macro',
'-Wno-nested-anon-types',
'-Wno-sign-compare',
- '-Wno-keyword-macro',
+ '-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
return flags