diff options
author | Gabriel Ganne <gabriel.ganne@mindmaze.com> | 2019-09-09 09:15:38 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-09-14 05:51:36 +0300 |
commit | e7197895b27a789a4339b493ceddb242f7f12c9e (patch) | |
tree | d2c687fbd181bea66a60706f31b345279ff69839 /mesonbuild/scripts | |
parent | 9e04450eb694c91dcb097a388c7bf4ecc7290545 (diff) | |
download | meson-e7197895b27a789a4339b493ceddb242f7f12c9e.zip meson-e7197895b27a789a4339b493ceddb242f7f12c9e.tar.gz meson-e7197895b27a789a4339b493ceddb242f7f12c9e.tar.bz2 |
uniform scan-build detection process
Detect scan-build the same way when trying to launch it and when
generating the target.
The detection method is:
1. look within SCANBUILD env variable
2. shutil.which('scan-build')
3. *on non-linux platforms only*: go through all the possible
name candidates and test them individually.
The third step is added following this comment
https://github.com/mesonbuild/meson/pull/5857#issuecomment-528305788
However, going through a list of all the possible candidates is neither
easily maintainable nor performant, and is therefore skipped on
platforms that should not require such a step (currently, only Linux
platforms).
This is a follow-up to the issue raised by @lantw44 during PR:
https://github.com/mesonbuild/meson/pull/5857
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r-- | mesonbuild/scripts/scanbuild.py | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/mesonbuild/scripts/scanbuild.py b/mesonbuild/scripts/scanbuild.py index 8c0f423..d83ca12 100644 --- a/mesonbuild/scripts/scanbuild.py +++ b/mesonbuild/scripts/scanbuild.py @@ -16,9 +16,10 @@ import os import subprocess import shutil import tempfile -from ..environment import detect_ninja +from ..environment import detect_ninja, detect_scanbuild from ..mesonlib import Popen_safe, split_args + def scanbuild(exelist, srcdir, blddir, privdir, logdir, args): with tempfile.TemporaryDirectory(dir=privdir) as scandir: meson_cmd = exelist + args @@ -28,6 +29,7 @@ def scanbuild(exelist, srcdir, blddir, privdir, logdir, args): return rc return subprocess.call(build_cmd) + def run(args): srcdir = args[0] blddir = args[1] @@ -35,40 +37,10 @@ def run(args): privdir = os.path.join(blddir, 'meson-private') logdir = os.path.join(blddir, 'meson-logs/scanbuild') shutil.rmtree(logdir, ignore_errors=True) - tools = [ - 'scan-build', # base - 'scan-build-8.0', 'scan-build80', - 'scan-build-7.0', 'scan-build70', - 'scan-build-6.0', 'scan-build60', - 'scan-build-5.0', 'scan-build50', - 'scan-build-4.0', 'scan-build40', - 'scan-build-3.9', 'scan-build39', - 'scan-build-3.8', 'scan-build38', - 'scan-build-3.7', 'scan-build37', - 'scan-build-3.6', 'scan-build36', - 'scan-build-3.5', 'scan-build35', - 'scan-build-9.0', 'scan-build-devel', # development snapshot - ] - toolname = 'scan-build' - for tool in tools: - try: - p, out = Popen_safe([tool, '--help'])[:2] - except (FileNotFoundError, PermissionError): - continue - if p.returncode != 0: - continue - else: - toolname = tool - break - if 'SCANBUILD' in os.environ: - exelist = split_args(os.environ['SCANBUILD']) - else: - exelist = [toolname] - - try: - Popen_safe(exelist + ['--help']) - except OSError: + exelist = detect_scanbuild() + if not exelist: print('Could not execute scan-build "%s"' % ' '.join(exelist)) return 1 + return scanbuild(exelist, srcdir, blddir, privdir, logdir, meson_cmd) |