blob: 4ca97402a97ff0d30acc95537c79460acf06cb9e [file] [log] [blame]
Alexander Afanasyev67758b12018-03-06 18:36:44 -05001from waflib import TaskGen
Yingdi Yu40cd1c32014-04-17 15:02:17 -07002
3def options(opt):
Alexander Afanasyev67758b12018-03-06 18:36:44 -05004 opt.add_option('--with-coverage', action='store_true', default=False,
5 help='Add compiler flags to enable code coverage information')
Yingdi Yu40cd1c32014-04-17 15:02:17 -07006
7def configure(conf):
8 if conf.options.with_coverage:
Davide Pesavento6ebfd7c2017-08-26 17:52:54 -04009 if not conf.options.debug:
Alexander Afanasyev67758b12018-03-06 18:36:44 -050010 conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
Yingdi Yu40cd1c32014-04-17 15:02:17 -070011 conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
12 linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
13
14@TaskGen.feature('cxx','cc')
15@TaskGen.after('process_source')
16def add_coverage(self):
17 if getattr(self, 'use', ''):
18 self.use += ' GCOV'
19 else:
20 self.use = 'GCOV'