]>
git.proxmox.com Git - mirror_qemu.git/blob - scripts/qapi-gen.py
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.
12 from qapi
.commands
import gen_commands
13 from qapi
.doc
import gen_doc
14 from qapi
.events
import gen_events
15 from qapi
.introspect
import gen_introspect
16 from qapi
.schema
import QAPIError
, QAPISchema
17 from qapi
.types
import gen_types
18 from qapi
.visit
import gen_visit
22 parser
= argparse
.ArgumentParser(
23 description
='Generate code from a QAPI schema')
24 parser
.add_argument('-b', '--builtins', action
='store_true',
25 help="generate code for built-in types")
26 parser
.add_argument('-o', '--output-dir', action
='store', default
='',
27 help="write output to directory OUTPUT_DIR")
28 parser
.add_argument('-p', '--prefix', action
='store', default
='',
29 help="prefix for symbols")
30 parser
.add_argument('-u', '--unmask-non-abi-names', action
='store_true',
32 help="expose non-ABI names in introspection")
33 parser
.add_argument('schema', action
='store')
34 args
= parser
.parse_args()
36 match
= re
.match(r
'([A-Za-z_.-][A-Za-z0-9_.-]*)?', args
.prefix
)
37 if match
.end() != len(args
.prefix
):
38 print("%s: 'funny character '%s' in argument of --prefix"
39 % (sys
.argv
[0], args
.prefix
[match
.end()]),
44 schema
= QAPISchema(args
.schema
)
45 except QAPIError
as err
:
46 print(err
, file=sys
.stderr
)
49 gen_types(schema
, args
.output_dir
, args
.prefix
, args
.builtins
)
50 gen_visit(schema
, args
.output_dir
, args
.prefix
, args
.builtins
)
51 gen_commands(schema
, args
.output_dir
, args
.prefix
)
52 gen_events(schema
, args
.output_dir
, args
.prefix
)
53 gen_introspect(schema
, args
.output_dir
, args
.prefix
, args
.unmask
)
54 gen_doc(schema
, args
.output_dir
, args
.prefix
)
57 if __name__
== '__main__':