target/hppa: Convert arithmetic immediate insns
[qemu/ar7.git] / scripts / qapi-gen.py
blob3d98ca2e0c6eb900487b60a52faadaf156935ddf
1 #!/usr/bin/env python
2 # QAPI generator
4 # This work is licensed under the terms of the GNU GPL, version 2 or later.
5 # See the COPYING file in the top-level directory.
7 from __future__ import print_function
8 import argparse
9 import re
10 import sys
11 from qapi.common import QAPIError, QAPISchema
12 from qapi.types import gen_types
13 from qapi.visit import gen_visit
14 from qapi.commands import gen_commands
15 from qapi.events import gen_events
16 from qapi.introspect import gen_introspect
17 from qapi.doc import gen_doc
20 def main(argv):
21 parser = argparse.ArgumentParser(
22 description='Generate code from a QAPI schema')
23 parser.add_argument('-b', '--builtins', action='store_true',
24 help="generate code for built-in types")
25 parser.add_argument('-o', '--output-dir', action='store', default='',
26 help="write output to directory OUTPUT_DIR")
27 parser.add_argument('-p', '--prefix', action='store', default='',
28 help="prefix for symbols")
29 parser.add_argument('-u', '--unmask-non-abi-names', action='store_true',
30 dest='unmask',
31 help="expose non-ABI names in introspection")
32 parser.add_argument('schema', action='store')
33 args = parser.parse_args()
35 match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', args.prefix)
36 if match.end() != len(args.prefix):
37 print("%s: 'funny character '%s' in argument of --prefix"
38 % (sys.argv[0], args.prefix[match.end()]),
39 file=sys.stderr)
40 sys.exit(1)
42 try:
43 schema = QAPISchema(args.schema)
44 except QAPIError as err:
45 print(err, file=sys.stderr)
46 exit(1)
48 gen_types(schema, args.output_dir, args.prefix, args.builtins)
49 gen_visit(schema, args.output_dir, args.prefix, args.builtins)
50 gen_commands(schema, args.output_dir, args.prefix)
51 gen_events(schema, args.output_dir, args.prefix)
52 gen_introspect(schema, args.output_dir, args.prefix, args.unmask)
53 gen_doc(schema, args.output_dir, args.prefix)
56 if __name__ == '__main__':
57 main(sys.argv)