blob: 4ca97402a97ff0d30acc95537c79460acf06cb9e [file] [log] [blame]
Davide Pesavento55d98602019-10-15 22:40:05 -04001from waflib import TaskGen
Zhiyi Zhang8617a792017-01-17 16:45:56 -08002
3def options(opt):
Davide Pesavento55d98602019-10-15 22:40:05 -04004 opt.add_option('--with-coverage', action='store_true', default=False,
5 help='Add compiler flags to enable code coverage information')
Zhiyi Zhang8617a792017-01-17 16:45:56 -08006
7def configure(conf):
8 if conf.options.with_coverage:
9 if not conf.options.debug:
Davide Pesavento55d98602019-10-15 22:40:05 -040010 conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080011 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'