blob: cc5816500a9542b2f2ffeaee7e5094556db503fc [file] [log] [blame]
Alexander Afanasyev4ffcff22014-09-02 15:39:20 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev4ffcff22014-09-02 15:39:20 -07002
Alexander Afanasyev08d18742018-03-15 16:31:28 -04003from waflib import TaskGen
Alexander Afanasyev4ffcff22014-09-02 15:39:20 -07004
5def options(opt):
Alexander Afanasyev08d18742018-03-15 16:31:28 -04006 opt.add_option('--with-coverage', action='store_true', default=False,
7 help='Add compiler flags to enable code coverage information')
Alexander Afanasyev4ffcff22014-09-02 15:39:20 -07008
9def configure(conf):
10 if conf.options.with_coverage:
Alexander Afanasyev984ca9d2016-12-19 13:09:14 -080011 if not conf.options.debug:
Alexander Afanasyev08d18742018-03-15 16:31:28 -040012 conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
Alexander Afanasyev4ffcff22014-09-02 15:39:20 -070013 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'