diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2018-03-05 09:47:37 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2018-03-05 09:47:37 +0000 |
| commit | 7fceeb190ac6fbbbec0bf904f743190708301e31 (patch) | |
| tree | 65daba4301f340e0678bd86741e947039120f4cb /scripts/qapi-gen.py | |
| parent | 4f51e1d386e306a6a94ee997651f580e1c9f7b54 (diff) | |
| parent | 418b1d0ae3a2cc992659f626a2a3f11944e0b259 (diff) | |
| download | focaccia-qemu-7fceeb190ac6fbbbec0bf904f743190708301e31.tar.gz focaccia-qemu-7fceeb190ac6fbbbec0bf904f743190708301e31.zip | |
Merge remote-tracking branch 'remotes/ericb/tags/pull-qapi-2018-03-01-v4' into staging
qapi patches for 2018-03-01 - Markus Armbruster: Modularize generated QAPI code # gpg: Signature made Fri 02 Mar 2018 19:50:16 GMT # gpg: using RSA key A7A16B4A2527436A # gpg: Good signature from "Eric Blake <eblake@redhat.com>" # gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" # gpg: aka "[jpeg image of size 6874]" # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-qapi-2018-03-01-v4: (30 commits) qapi: Don't create useless directory qapi-generated Fix up dangling references to qmp-commands.* in comment and doc qapi: Move qapi-schema.json to qapi/, rename generated files docs: Correct outdated information on QAPI docs/devel/writing-qmp-commands: Update for modular QAPI qapi: Empty out qapi-schema.json Include less of the generated modular QAPI headers qapi: Generate separate .h, .c for each module watchdog: Consolidate QAPI into single file qapi/common: Fix guardname() for funny filenames qapi/types qapi/visit: Generate built-in stuff into separate files qapi: Make code-generating visitors use QAPIGen more qapi: Rename generated qmp-marshal.c to qmp-commands.c qapi: Record 'include' directives in intermediate representation qapi: Generate in source order qapi: Record 'include' directives in parse tree qapi: Concentrate QAPISchemaParser.exprs updates in .__init__() qapi: Lift error reporting from QAPISchema.__init__() to callers qapi/common: Eliminate QAPISchema.exprs qapi: Improve include file name reporting in error messages ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi-gen.py')
| -rwxr-xr-x | scripts/qapi-gen.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py new file mode 100755 index 0000000000..3d98ca2e0c --- /dev/null +++ b/scripts/qapi-gen.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# QAPI generator +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +from __future__ import print_function +import argparse +import re +import sys +from qapi.common import QAPIError, QAPISchema +from qapi.types import gen_types +from qapi.visit import gen_visit +from qapi.commands import gen_commands +from qapi.events import gen_events +from qapi.introspect import gen_introspect +from qapi.doc import gen_doc + + +def main(argv): + parser = argparse.ArgumentParser( + description='Generate code from a QAPI schema') + parser.add_argument('-b', '--builtins', action='store_true', + help="generate code for built-in types") + parser.add_argument('-o', '--output-dir', action='store', default='', + help="write output to directory OUTPUT_DIR") + parser.add_argument('-p', '--prefix', action='store', default='', + help="prefix for symbols") + parser.add_argument('-u', '--unmask-non-abi-names', action='store_true', + dest='unmask', + help="expose non-ABI names in introspection") + parser.add_argument('schema', action='store') + args = parser.parse_args() + + match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', args.prefix) + if match.end() != len(args.prefix): + print("%s: 'funny character '%s' in argument of --prefix" + % (sys.argv[0], args.prefix[match.end()]), + file=sys.stderr) + sys.exit(1) + + try: + schema = QAPISchema(args.schema) + except QAPIError as err: + print(err, file=sys.stderr) + exit(1) + + gen_types(schema, args.output_dir, args.prefix, args.builtins) + gen_visit(schema, args.output_dir, args.prefix, args.builtins) + gen_commands(schema, args.output_dir, args.prefix) + gen_events(schema, args.output_dir, args.prefix) + gen_introspect(schema, args.output_dir, args.prefix, args.unmask) + gen_doc(schema, args.output_dir, args.prefix) + + +if __name__ == '__main__': + main(sys.argv) |