Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright (c) 2014, Regents of the University of California |
| 4 | # |
| 5 | # GPL 3.0 license, see the COPYING.md file for more information |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 6 | |
| 7 | from waflib import TaskGen |
| 8 | |
| 9 | def options(opt): |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 10 | opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage', |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 11 | help='''Set compiler flags for gcc to enable code coverage information''') |
| 12 | |
| 13 | def configure(conf): |
| 14 | if conf.options.with_coverage: |
| 15 | conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'], |
| 16 | linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True) |
| 17 | |
| 18 | @TaskGen.feature('cxx','cc') |
| 19 | @TaskGen.after('process_source') |
| 20 | def add_coverage(self): |
| 21 | if getattr(self, 'use', ''): |
| 22 | self.use += ' GCOV' |
| 23 | else: |
| 24 | self.use = 'GCOV' |