mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
meson: add sparse support
Do not use cgcc; instead, extract compilation commands from compile_commands.json and invoke sparse directly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
bf0e56a3ca
commit
968b4db38a
4 changed files with 35 additions and 6 deletions
25
scripts/check_sparse.py
Normal file
25
scripts/check_sparse.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
# Invoke sparse based on the contents of compile_commands.json
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import shlex
|
||||
|
||||
def extract_cflags(shcmd):
|
||||
cflags = shlex.split(shcmd)
|
||||
return [x for x in cflags
|
||||
if x.startswith('-D') or x.startswith('-I') or x.startswith('-W')
|
||||
or x.startswith('-std=')]
|
||||
|
||||
cflags = sys.argv[1:-1]
|
||||
with open(sys.argv[-1], 'r') as fd:
|
||||
compile_commands = json.load(fd)
|
||||
|
||||
for cmd in compile_commands:
|
||||
cmd = ['sparse'] + cflags + extract_cflags(cmd['command']) + [cmd['file']]
|
||||
print(' '.join((shlex.quote(x) for x in cmd)))
|
||||
r = subprocess.run(cmd)
|
||||
if r.returncode != 0:
|
||||
sys.exit(r.returncode)
|
Loading…
Add table
Add a link
Reference in a new issue