Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | from waflib import TaskGen |
| 4 | |
| 5 | def options(opt): |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 6 | opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage', |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 7 | help='''Set compiler flags for gcc to enable code coverage information''') |
| 8 | |
| 9 | def configure(conf): |
| 10 | if conf.options.with_coverage: |
| 11 | 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') |
| 16 | def add_coverage(self): |
| 17 | if getattr(self, 'use', ''): |
| 18 | self.use += ' GCOV' |
| 19 | else: |
| 20 | self.use = 'GCOV' |