diff options
author | Joel Klinghed <the_jk@spawned.biz> | 2018-02-27 21:46:08 +0100 |
---|---|---|
committer | Joel Klinghed <the_jk@spawned.biz> | 2018-02-27 21:58:05 +0100 |
commit | 6266089866469c2a2d298b79df74d2aad86bbeea (patch) | |
tree | dfdcd675b8a367c6433f7e3aa034a283be6379d7 /mesonbuild/backend/ninjabackend.py | |
parent | da017702613d718ac69ae213ee91358566f7b622 (diff) | |
download | meson-6266089866469c2a2d298b79df74d2aad86bbeea.zip meson-6266089866469c2a2d298b79df74d2aad86bbeea.tar.gz meson-6266089866469c2a2d298b79df74d2aad86bbeea.tar.bz2 |
Allow gcovr >= 3.1 to be used to generate html coverage report
Modern gcovr includes html generation support so if lcov and
genhtml are not available fallback to gcovr.
Kept lcov and genhtml as default so to not surprise existing
users of coverage-html with the different output of gcovr.
gcovr added html support in 3.0 but as there already is a test
for 3.1 because of the changes to -r/--rootdir I opted to only
allow html generation for >= 3.1 to keep things simple.
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 92d7dfb..54d1545 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -668,6 +668,19 @@ int dummy; elem.add_item('COMMAND', command) elem.add_item('DESC', 'Generating HTML coverage report.') elem.write(outfile) + elif gcovr_exe and gcovr_3_1: + added_rule = True + htmloutdir = os.path.join(self.environment.get_log_dir(), 'coveragereport') + phony_elem = NinjaBuildElement(self.all_outputs, 'meson-coverage-html', 'phony', os.path.join(htmloutdir, 'index.html')) + phony_elem.write(outfile) + # Alias that runs the target defined above + self.create_target_alias('meson-coverage-html', outfile) + elem = NinjaBuildElement(self.all_outputs, os.path.join(htmloutdir, 'index.html'), 'CUSTOM_COMMAND', '') + command = [gcovr_exe, '--html', '--html-details', '-r', self.environment.get_build_dir(), + '-o', os.path.join(htmloutdir, 'index.html')] + elem.add_item('COMMAND', command) + elem.add_item('DESC', 'Generating HTML coverage report.') + elem.write(outfile) if not added_rule: mlog.warning('coverage requested but neither gcovr nor lcov/genhtml found.') |