summaryrefslogtreecommitdiff
path: root/scripts/qapi-gen.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2018-02-26 13:48:58 -0600
committerEric Blake <eblake@redhat.com>2018-03-02 13:14:09 -0600
commitfb0bc835e56b894cbc7236294921e5393c786ad8 (patch)
treec96c6626054c20084fc9fe268fab187c0bed20bf /scripts/qapi-gen.py
parent26df4e7fab06422b21e11d039c64243ca4003147 (diff)
downloadqemu-fb0bc835e56b894cbc7236294921e5393c786ad8.tar.gz
qapi-gen: New common driver for code and doc generators
Whenever qapi-schema.json changes, we run six programs eleven times to update eleven files. Similar for qga/qapi-schema.json. This is silly. Replace the six programs by a single program that spits out all eleven files. The programs become modules in new Python package qapi, along with the helper library. This requires moving them to scripts/qapi/. While moving them, consistently drop executable mode bits. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20180211093607.27351-9-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> [eblake: move change to one-line 'blurb' earlier in series, mention mode bit change as intentional, update qapi-code-gen.txt to match actual generated events.c file] Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi-gen.py')
-rwxr-xr-xscripts/qapi-gen.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py
new file mode 100755
index 0000000000..2100ca1145
--- /dev/null
+++ b/scripts/qapi-gen.py
@@ -0,0 +1,41 @@
+#!/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.
+
+import sys
+from qapi.common import parse_command_line, 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):
+ (input_file, output_dir, prefix, opts) = \
+ parse_command_line('bu', ['builtins', 'unmask-non-abi-names'])
+
+ opt_builtins = False
+ opt_unmask = False
+
+ for o, a in opts:
+ if o in ('-b', '--builtins'):
+ opt_builtins = True
+ if o in ('-u', '--unmask-non-abi-names'):
+ opt_unmask = True
+
+ schema = QAPISchema(input_file)
+
+ gen_types(schema, output_dir, prefix, opt_builtins)
+ gen_visit(schema, output_dir, prefix, opt_builtins)
+ gen_commands(schema, output_dir, prefix)
+ gen_events(schema, output_dir, prefix)
+ gen_introspect(schema, output_dir, prefix, opt_unmask)
+ gen_doc(schema, output_dir, prefix)
+
+
+if __name__ == '__main__':
+ main(sys.argv)