Exclude subprojects when doing coverage

pull/3214/head
Niklas Claesson 7 years ago committed by Jussi Pakkanen
parent 52c50da6c7
commit 7074bcb88a
  1. 29
      mesonbuild/backend/ninjabackend.py
  2. 4
      mesonbuild/build.py
  3. 2
      mesonbuild/interpreter.py

@ -655,11 +655,30 @@ int dummy;
# Alias that runs the target defined above # Alias that runs the target defined above
self.create_target_alias('meson-coverage-html', outfile) self.create_target_alias('meson-coverage-html', outfile)
elem = NinjaBuildElement(self.all_outputs, os.path.join(htmloutdir, 'index.html'), 'CUSTOM_COMMAND', '') 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', subproject_dir = self.build.get_subproject_dir()
'&&', genhtml_exe, '--prefix', self.environment.get_build_dir(), command = [lcov_exe,
'--output-directory', htmloutdir, '--title', 'Code coverage', '--directory', self.environment.get_build_dir(),
'--legend', '--show-details', covinfo] '--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('COMMAND', command)
elem.add_item('DESC', 'Generating HTML coverage report.') elem.add_item('DESC', 'Generating HTML coverage report.')
elem.write(outfile) elem.write(outfile)

@ -114,6 +114,7 @@ class Build:
self.static_linker = None self.static_linker = None
self.static_cross_linker = None self.static_cross_linker = None
self.subprojects = {} self.subprojects = {}
self.subproject_dir = ''
self.install_scripts = [] self.install_scripts = []
self.postconf_scripts = [] self.postconf_scripts = []
self.install_dirs = [] self.install_dirs = []
@ -139,6 +140,9 @@ class Build:
def get_project(self): def get_project(self):
return self.projects[''] return self.projects['']
def get_subproject_dir(self):
return self.subproject_dir
def get_targets(self): def get_targets(self):
return self.targets return self.targets

@ -1945,6 +1945,8 @@ to directly access options of other subprojects.''')
raise InterpreterException('Subproject_dir must not contain a ".." segment.') raise InterpreterException('Subproject_dir must not contain a ".." segment.')
self.subproject_dir = spdirname self.subproject_dir = spdirname
self.build.subproject_dir = self.subproject_dir
if 'meson_version' in kwargs: if 'meson_version' in kwargs:
cv = coredata.version cv = coredata.version
pv = kwargs['meson_version'] pv = kwargs['meson_version']

Loading…
Cancel
Save