aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/scanbuild.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-05-22 19:24:59 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2016-05-22 19:24:59 +0300
commit1a0938cc250d6202ffb099fba40b58fb5880c90c (patch)
tree8a839c455c98eafe2c2aa5d38f2d1143be94ed94 /mesonbuild/scripts/scanbuild.py
parent1574471822f8a034b33cb79f5e18f2c597a7dec5 (diff)
downloadmeson-1a0938cc250d6202ffb099fba40b58fb5880c90c.zip
meson-1a0938cc250d6202ffb099fba40b58fb5880c90c.tar.gz
meson-1a0938cc250d6202ffb099fba40b58fb5880c90c.tar.bz2
Automagic scan-build support.
Diffstat (limited to 'mesonbuild/scripts/scanbuild.py')
-rw-r--r--mesonbuild/scripts/scanbuild.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/mesonbuild/scripts/scanbuild.py b/mesonbuild/scripts/scanbuild.py
new file mode 100644
index 0000000..f90c3c7
--- /dev/null
+++ b/mesonbuild/scripts/scanbuild.py
@@ -0,0 +1,39 @@
+# Copyright 2016 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys, os
+import subprocess
+import shutil
+import tempfile
+
+def scanbuild(srcdir, blddir, privdir, logdir, args):
+ with tempfile.TemporaryDirectory(dir=privdir) as scandir:
+ meson_cmd = ['scan-build'] + args
+ build_cmd = ['scan-build', '-o', logdir, 'ninja']
+ rc = subprocess.call(meson_cmd + [srcdir, scandir])
+ if rc != 0:
+ return rc
+ return subprocess.call(build_cmd)
+
+def run(args):
+ srcdir = args[0]
+ blddir = args[1]
+ meson_cmd = args[2:]
+ privdir = os.path.join(blddir, 'meson-private')
+ logdir = os.path.join(blddir, 'meson-logs/scanbuild')
+ shutil.rmtree(logdir, ignore_errors=True)
+ if not shutil.which('scan-build'):
+ print('Scan-build not installed')
+ return 1
+ return scanbuild(srcdir, blddir, privdir, logdir, meson_cmd)