diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-10-12 11:29:41 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2020-10-12 11:29:42 +0100 |
| commit | 2387df497b4b4bcf754eb7398edca82889e2ef54 (patch) | |
| tree | 11d3099549e5d67012a4f0818a41ede540940a36 /scripts/qapi-gen.py | |
| parent | 48a340d9b23ffcf7704f2de14d1e505481a84a1c (diff) | |
| parent | b4c0aa59aff520e2a55edd5fef393058ca6520de (diff) | |
| download | focaccia-qemu-2387df497b4b4bcf754eb7398edca82889e2ef54.tar.gz focaccia-qemu-2387df497b4b4bcf754eb7398edca82889e2ef54.zip | |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-10-10' into staging
QAPI patches patches for 2020-10-10 # gpg: Signature made Sat 10 Oct 2020 10:43:14 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2020-10-10: (34 commits) qapi/visit.py: add type hint annotations qapi/visit.py: remove unused parameters from gen_visit_object qapi/visit.py: assert tag_member contains a QAPISchemaEnumType qapi/types.py: remove one-letter variables qapi/types.py: add type hint annotations qapi/gen.py: delint with pylint qapi/gen.py: update write() to be more idiomatic qapi/gen.py: Remove unused parameter qapi/gen.py: add type hint annotations qapi/gen: Make _is_user_module() return bool qapi/source.py: delint with pylint qapi/source.py: add type hint annotations qapi/commands.py: add type hint annotations qapi/commands.py: Don't re-bind to variable of different type qapi/events.py: Move comments into docstrings qapi/events.py: add type hint annotations qapi: establish mypy type-checking baseline qapi/common.py: move build_params into gen.py qapi/common.py: Convert comments into docstrings, and elaborate qapi/common.py: add type hint annotations ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi-gen.py')
| -rw-r--r-- | scripts/qapi-gen.py | 57 |
1 files changed, 10 insertions, 47 deletions
diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py index 541e8c1f55..f3518d29a5 100644 --- a/scripts/qapi-gen.py +++ b/scripts/qapi-gen.py @@ -1,56 +1,19 @@ #!/usr/bin/env python3 -# 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. +""" +QAPI code generation execution shim. -import argparse -import re -import sys - -from qapi.commands import gen_commands -from qapi.events import gen_events -from qapi.introspect import gen_introspect -from qapi.schema import QAPIError, QAPISchema -from qapi.types import gen_types -from qapi.visit import gen_visit - +This standalone script exists primarily to facilitate the running of the QAPI +code generator without needing to install the python module to the current +execution environment. +""" -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) +import sys +from qapi import main if __name__ == '__main__': - main(sys.argv) + sys.exit(main.main()) |