Automagic scan-build support.

pull/556/head
Jussi Pakkanen 9 years ago
parent 1574471822
commit 1a0938cc25
  1. 11
      mesonbuild/backend/ninjabackend.py
  2. 1
      mesonbuild/coredata.py
  3. 3
      mesonbuild/mesonmain.py
  4. 39
      mesonbuild/scripts/scanbuild.py

@ -188,6 +188,7 @@ int dummy;
outfile.write('# Coverage rules\n\n')
self.generate_coverage_rules(outfile)
outfile.write('# Suffix\n\n')
self.generate_utils(outfile)
self.generate_ending(outfile)
# Only ovewrite the old build file after the new one has been
# fully created.
@ -1797,6 +1798,16 @@ rule FORTRAN_DEP_HACK
other_deps.append(outfilename)
return (src_deps, other_deps)
# For things like scan-build and other helper tools we might have.
def generate_utils(self, outfile):
cmd = [sys.executable, self.environment.get_build_command(),
'--internal', 'scanbuild', self.environment.source_dir, self.environment.build_dir,
sys.executable, self.environment.get_build_command()]
elem = NinjaBuildElement(self.all_outputs, 'scan-build', 'CUSTOM_COMMAND', 'PHONY')
elem.add_item('COMMAND', cmd)
elem.add_item('pool', 'console')
elem.write(outfile)
def generate_ending(self, outfile):
targetlist = [self.get_target_filename(t) for t in self.build.get_targets().values()\
if not isinstance(t, build.RunTarget)]

@ -229,4 +229,5 @@ forbidden_target_names = {'clean': None,
'benchmark': None,
'install': None,
'build.ninja': None,
'scan-build': None,
}

@ -196,6 +196,9 @@ def run_script_command(args):
elif cmdname == 'symbolextractor':
import mesonbuild.scripts.symbolextractor as abc
cmdfunc = abc.run
elif cmdname == 'scanbuild':
import mesonbuild.scripts.scanbuild as abc
cmdfunc = abc.run
elif cmdname == 'vcstagger':
import mesonbuild.scripts.vcstagger as abc
cmdfunc = abc.run

@ -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)
Loading…
Cancel
Save