Skip to content

Commit

Permalink
scan-build: Exclude subprojects from scan-build report
Browse files Browse the repository at this point in the history
When a user invokes the scan-build target that Meson generates
all subprojects are included in the resulting report. This commit
modifies the invocation of scan-build to exclude all bugs that
scan-build finds in the subprojects from the final report.
  • Loading branch information
amcn committed Nov 2, 2023
1 parent b200062 commit 8b92aab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3587,7 +3587,7 @@ def generate_scanbuild(self) -> None:
if 'scan-build' in self.all_outputs:
return
cmd = self.environment.get_build_command() + \
['--internal', 'scanbuild', self.environment.source_dir, self.environment.build_dir] + \
['--internal', 'scanbuild', self.environment.source_dir, self.environment.build_dir, self.build.get_subproject_dir()] + \
self.environment.get_build_command() + self.get_user_option_args()
elem = self.create_phony_target('scan-build', 'CUSTOM_COMMAND', 'PHONY')
elem.add_item('COMMAND', cmd)
Expand Down
9 changes: 5 additions & 4 deletions mesonbuild/scripts/scanbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
from ast import literal_eval
import os

def scanbuild(exelist: T.List[str], srcdir: Path, blddir: Path, privdir: Path, logdir: Path, args: T.List[str]) -> int:
def scanbuild(exelist: T.List[str], srcdir: Path, blddir: Path, privdir: Path, logdir: Path, subprojdir: Path, args: T.List[str]) -> int:
# In case of problems leave the temp directory around
# so it can be debugged.
scandir = tempfile.mkdtemp(dir=str(privdir))
meson_cmd = exelist + args
build_cmd = exelist + ['-o', str(logdir)] + detect_ninja() + ['-C', scandir]
build_cmd = exelist + ['--exclude', str(subprojdir), '-o', str(logdir)] + detect_ninja() + ['-C', scandir]
rc = subprocess.call(meson_cmd + [str(srcdir), scandir])
if rc != 0:
return rc
Expand All @@ -41,8 +41,9 @@ def scanbuild(exelist: T.List[str], srcdir: Path, blddir: Path, privdir: Path, l
def run(args: T.List[str]) -> int:
srcdir = Path(args[0])
bldpath = Path(args[1])
subprojdir = srcdir / Path(args[2])
blddir = args[1]
meson_cmd = args[2:]
meson_cmd = args[3:]
privdir = bldpath / 'meson-private'
logdir = bldpath / 'meson-logs' / 'scanbuild'
shutil.rmtree(str(logdir), ignore_errors=True)
Expand All @@ -63,4 +64,4 @@ def run(args: T.List[str]) -> int:
print('Could not execute scan-build "%s"' % ' '.join(exelist))
return 1

return scanbuild(exelist, srcdir, bldpath, privdir, logdir, meson_cmd)
return scanbuild(exelist, srcdir, bldpath, privdir, logdir, subprojdir, meson_cmd)

0 comments on commit 8b92aab

Please sign in to comment.