blob: ce928838afa2e511b48e4b308ffb5035bc8eedf6 [file] [log] [blame]
Alexander Afanasyev689569b2014-02-16 20:20:07 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -08003from waflib import TaskGen, Logs
Alexander Afanasyev689569b2014-02-16 20:20:07 -08004
5def options(opt):
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -07006 opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage',
Alexander Afanasyev689569b2014-02-16 20:20:07 -08007 help='''Set compiler flags for gcc to enable code coverage information''')
8
9def configure(conf):
10 if conf.options.with_coverage:
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080011 if not conf.options.debug:
12 conf.fatal("Code coverage flags require debug mode compilation (add --debug)")
Alexander Afanasyev689569b2014-02-16 20:20:07 -080013 conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
14 linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
15
16@TaskGen.feature('cxx','cc')
17@TaskGen.after('process_source')
18def add_coverage(self):
19 if getattr(self, 'use', ''):
20 self.use += ' GCOV'
21 else:
22 self.use = 'GCOV'