blob: cc5816500a9542b2f2ffeaee7e5094556db503fc [file] [log] [blame]
Alexander Afanasyevf5df8e62014-02-16 19:56:21 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev5560fd42018-03-07 17:03:03 -05003from waflib import TaskGen
Alexander Afanasyevf5df8e62014-02-16 19:56:21 -08004
5def options(opt):
Alexander Afanasyev5560fd42018-03-07 17:03:03 -05006 opt.add_option('--with-coverage', action='store_true', default=False,
7 help='Add compiler flags to enable code coverage information')
Alexander Afanasyevf5df8e62014-02-16 19:56:21 -08008
9def configure(conf):
10 if conf.options.with_coverage:
Alexander Afanasyev4c32e742014-11-09 21:37:12 -080011 if not conf.options.debug:
Alexander Afanasyev5560fd42018-03-07 17:03:03 -050012 conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
Alexander Afanasyevf5df8e62014-02-16 19:56:21 -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'