aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2018-10-08 09:41:16 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2018-10-08 20:21:32 +0300
commit1e7aea65e68a43b0319a4a28908daddfec621548 (patch)
treebd48f2780d494b3ae7f3223071d1dd77006fe8f4 /mesonbuild/scripts
parentce2eed32bcfaaea5fa551495377a1b4eaa44ea78 (diff)
downloadmeson-1e7aea65e68a43b0319a4a28908daddfec621548.zip
meson-1e7aea65e68a43b0319a4a28908daddfec621548.tar.gz
meson-1e7aea65e68a43b0319a4a28908daddfec621548.tar.bz2
scanbuild: Split SCANBUILD using shlex
This allows invocations like SCANBUILD="scan-build --status-bugs" ninja scan-build Closes: #4334
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/scanbuild.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/mesonbuild/scripts/scanbuild.py b/mesonbuild/scripts/scanbuild.py
index f381552..1c86bf1 100644
--- a/mesonbuild/scripts/scanbuild.py
+++ b/mesonbuild/scripts/scanbuild.py
@@ -13,16 +13,17 @@
# limitations under the License.
import os
+import shlex
import subprocess
import shutil
import tempfile
from ..environment import detect_ninja
from ..mesonlib import Popen_safe
-def scanbuild(exename, srcdir, blddir, privdir, logdir, args):
+def scanbuild(exelist, srcdir, blddir, privdir, logdir, args):
with tempfile.TemporaryDirectory(dir=privdir) as scandir:
- meson_cmd = [exename] + args
- build_cmd = [exename, '-o', logdir, detect_ninja(), '-C', scandir]
+ meson_cmd = exelist + args
+ build_cmd = exelist + ['-o', logdir, detect_ninja(), '-C', scandir]
rc = subprocess.call(meson_cmd + [srcdir, scandir])
if rc != 0:
return rc
@@ -58,8 +59,14 @@ def run(args):
toolname = tool
break
- exename = os.environ.get('SCANBUILD', toolname)
- if not shutil.which(exename):
- print('Scan-build not installed.')
+ if 'SCANBUILD' in os.environ:
+ exelist = shlex.split(os.environ['SCANBUILD'])
+ else:
+ exelist = [toolname]
+
+ try:
+ Popen_safe(exelist + ['--help'])
+ except OSError:
+ print('Could not execute scan-build "%s"' % ' '.join(exelist))
return 1
- return scanbuild(exename, srcdir, blddir, privdir, logdir, meson_cmd)
+ return scanbuild(exelist, srcdir, blddir, privdir, logdir, meson_cmd)