]> Git Repo - qemu.git/blob - scripts/check_sparse.py
Merge remote-tracking branch 'remotes/hdeller/tags/target-hppa-v3-pull-request' into...
[qemu.git] / scripts / check_sparse.py
1 #! /usr/bin/env python3
2
3 # Invoke sparse based on the contents of compile_commands.json
4
5 import json
6 import subprocess
7 import sys
8 import shlex
9
10 def extract_cflags(shcmd):
11     cflags = shlex.split(shcmd)
12     return [x for x in cflags
13             if x.startswith('-D') or x.startswith('-I') or x.startswith('-W')
14                or x.startswith('-std=')]
15
16 cflags = sys.argv[1:-1]
17 with open(sys.argv[-1], 'r') as fd:
18     compile_commands = json.load(fd)
19
20 for cmd in compile_commands:
21     cmd = ['sparse'] + cflags + extract_cflags(cmd['command']) + [cmd['file']]
22     print(' '.join((shlex.quote(x) for x in cmd)))
23     r = subprocess.run(cmd)
24     if r.returncode != 0:
25         sys.exit(r.returncode)
This page took 0.026271 seconds and 4 git commands to generate.