diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-03-01 23:38:51 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-03-01 23:38:51 +0200 |
commit | f7f726200a2b8d046b5248d3868fee4f860c1c6f (patch) | |
tree | 6242f3ff04b210bb2ea961119e988a82836a3b16 /backends.py | |
parent | 67b2ac474a3e1f9f5e121cec11cbc3c77ae8b223 (diff) | |
download | meson-f7f726200a2b8d046b5248d3868fee4f860c1c6f.zip meson-f7f726200a2b8d046b5248d3868fee4f860c1c6f.tar.gz meson-f7f726200a2b8d046b5248d3868fee4f860c1c6f.tar.bz2 |
Use NinjaBuildElements in coverage too.
Diffstat (limited to 'backends.py')
-rwxr-xr-x | backends.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/backends.py b/backends.py index d94d8ea..daf3aa9 100755 --- a/backends.py +++ b/backends.py @@ -254,28 +254,27 @@ class NinjaBackend(Backend): added_rule = False if gcovr_exe: added_rule = True - xmlbuild = 'build coverage-xml: CUSTOM_COMMAND\n' - xmlcommand = " COMMAND = '%s' -x -r '%s' -o coverage.xml\n\n" %\ - (ninja_quote(gcovr_exe), ninja_quote(self.environment.get_build_dir())) - outfile.write(xmlbuild) - outfile.write(xmlcommand) - textbuild = 'build coverage-text: CUSTOM_COMMAND\n' - textcommand = " COMMAND = '%s' -r '%s' -o coverage.txt\n\n" %\ - (ninja_quote(gcovr_exe), ninja_quote(self.environment.get_build_dir())) - outfile.write(textbuild) - outfile.write(textcommand) + elem = NinjaBuildElement('coverage-xml', 'CUSTOM_COMMAND', '') + elem.add_item('COMMAND', [gcovr_exe, '-x', '-r', self.environment.get_build_dir(),\ + '-o', 'coverage.xml']) + elem.write(outfile) + elem = NinjaBuildElement('coverage-text', 'CUSTOM_COMMAND', '') + elem.add_item('COMMAND', [gcovr_exe, '-r', self.environment.get_build_dir(),\ + '-o', 'coverage.txt']) + elem.write(outfile) if lcov_exe and genhtml_exe: added_rule = True - phony = 'build coverage-html: phony coveragereport/index.html\n' - htmlbuild = 'build coveragereport/index.html: CUSTOM_COMMAND\n' - lcov_command = "'%s' --directory '%s' --capture --output-file coverage.info --no-checksum" %\ - (ninja_quote(lcov_exe), ninja_quote(self.environment.get_build_dir())) - genhtml_command = "'%s' --prefix='%s' --output-directory coveragereport --title='Code coverage' --legend --show-details coverage.info" %\ - (ninja_quote(genhtml_exe), ninja_quote(self.environment.get_build_dir())) - command = ' COMMAND = %s && %s\n\n' % (lcov_command, genhtml_command) - outfile.write(phony) - outfile.write(htmlbuild) - outfile.write(command) + phony_elem = NinjaBuildElement('coverage-html', 'phony', 'coveragereport/index.html') + phony_elem.write(outfile) + + elem = NinjaBuildElement('coveragereport/index.html', 'CUSTOM_COMMAND', '') + command = [lcov_exe, '--directory', self.environment.get_build_dir(),\ + '--capture', '--output-file', 'coverage.info', '--no-checksum',\ + '&&', genhtml_exe, '--prefix', self.environment.get_build_dir(),\ + '--output-directory', 'coveragereport', '--title', 'Code coverage',\ + '--legend', '--show-details', 'coverage.info'] + elem.add_item('COMMAND', command) + elem.write(outfile) if not added_rule: print('Warning: coverage requested but neither gcovr nor lcov/genhtml found.') |