Alexander Afanasyev | 4ffcff2 | 2014-09-02 15:39:20 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 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 |
| 6 | |
| 7 | from waflib import TaskGen |
| 8 | |
| 9 | def options(opt): |
| 10 | opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage', |
| 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' |