aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Claesson <nicke.claesson@gmail.com>2018-03-08 16:01:06 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2018-03-10 18:05:35 +0200
commit7074bcb88a4e1f340ba7214b107b03c7f759d311 (patch)
tree760740da84683b6cfa45780a73336886ac969db6
parent52c50da6c7a921e1625fff26c7844af7d941afd9 (diff)
downloadmeson-7074bcb88a4e1f340ba7214b107b03c7f759d311.zip
meson-7074bcb88a4e1f340ba7214b107b03c7f759d311.tar.gz
meson-7074bcb88a4e1f340ba7214b107b03c7f759d311.tar.bz2
Exclude subprojects when doing coverage
-rw-r--r--mesonbuild/backend/ninjabackend.py29
-rw-r--r--mesonbuild/build.py4
-rw-r--r--mesonbuild/interpreter.py2
3 files changed, 30 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 376d32c..c13720f 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -655,11 +655,30 @@ int dummy;
# 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 = [lcov_exe, '--directory', self.environment.get_build_dir(),
- '--capture', '--output-file', covinfo, '--no-checksum',
- '&&', genhtml_exe, '--prefix', self.environment.get_build_dir(),
- '--output-directory', htmloutdir, '--title', 'Code coverage',
- '--legend', '--show-details', covinfo]
+
+ subproject_dir = self.build.get_subproject_dir()
+ command = [lcov_exe,
+ '--directory', self.environment.get_build_dir(),
+ '--capture',
+ '--output-file', covinfo,
+ '--no-checksum',
+ '&&', lcov_exe,
+ '--extract',
+ covinfo,
+ os.path.join(self.environment.get_source_dir(), '*'),
+ '--output-file', covinfo,
+ '&&', lcov_exe,
+ '--remove',
+ covinfo,
+ os.path.join(self.environment.get_source_dir(), subproject_dir, '*'),
+ '--output-file', covinfo,
+ '&&', genhtml_exe,
+ '--prefix', self.environment.get_build_dir(),
+ '--output-directory', htmloutdir,
+ '--title', 'Code coverage',
+ '--legend',
+ '--show-details',
+ covinfo]
elem.add_item('COMMAND', command)
elem.add_item('DESC', 'Generating HTML coverage report.')
elem.write(outfile)
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index d162e60..f4a5e2c 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -114,6 +114,7 @@ class Build:
self.static_linker = None
self.static_cross_linker = None
self.subprojects = {}
+ self.subproject_dir = ''
self.install_scripts = []
self.postconf_scripts = []
self.install_dirs = []
@@ -139,6 +140,9 @@ class Build:
def get_project(self):
return self.projects['']
+ def get_subproject_dir(self):
+ return self.subproject_dir
+
def get_targets(self):
return self.targets
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index f9f25e4..1bb8aab 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1945,6 +1945,8 @@ to directly access options of other subprojects.''')
raise InterpreterException('Subproject_dir must not contain a ".." segment.')
self.subproject_dir = spdirname
+ self.build.subproject_dir = self.subproject_dir
+
if 'meson_version' in kwargs:
cv = coredata.version
pv = kwargs['meson_version']