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/.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
.gitignore | 2 +
Makefile | 86 +++++++++----------
docs/devel/qapi-code-gen.txt | 97 ++++++++++------------
monitor.c | 2 +-
qapi-schema.json | 2 +-
scripts/qapi-gen.py | 41 +++++++++
scripts/qapi/__init__.py | 0
scripts/{qapi-commands.py => qapi/commands.py} | 23 ++---
scripts/{qapi.py => qapi/common.py} | 18 +---
scripts/{qapi2texi.py => qapi/doc.py} | 29 ++-----
scripts/{qapi-event.py => qapi/events.py} | 23 ++---
scripts/{qapi-introspect.py => qapi/introspect.py} | 32 ++-----
scripts/{qapi-types.py => qapi/types.py} | 34 ++------
scripts/{qapi-visit.py => qapi/visit.py} | 34 ++------
tests/Makefile.include | 56 ++++++-------
tests/qapi-schema/test-qapi.py | 4 +-
16 files changed, 193 insertions(+), 290 deletions(-)
create mode 100755 scripts/qapi-gen.py
create mode 100644 scripts/qapi/__init__.py
rename scripts/{qapi-commands.py => qapi/commands.py} (94%)
rename scripts/{qapi.py => qapi/common.py} (99%)
rename scripts/{qapi2texi.py => qapi/doc.py} (92%)
mode change 100755 => 100644
- $ python scripts/qapi-event.py --output-dir="qapi-generated"
- --prefix="example-" example-schema.json
$ cat qapi-generated/example-qapi-event.h
[Uninteresting stuff omitted...]
@@ -1302,23 +1296,22 @@ Example:
}
const char *const example_QAPIEvent_lookup[] = {
- [EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT",
+
+[EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT",
[EXAMPLE_QAPI_EVENT__MAX] = NULL,
};
+++ b/scripts/qapi/commands.py
@@ -13,7 +13,7 @@ This work is licensed under the terms of the GNU GPL, version
2.
See the COPYING file in the top-level directory.
"""
-from qapi import *
+from qapi.common import *
def gen_command_decl(name, arg_type, boxed, ret_type):
@@ -255,13 +255,8 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
self._regy += gen_register_command(name, success_response)
-def main(argv):
- (input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
-
- blurb = '''
- * Schema-defined QAPI/QMP commands
-'''
-
+def gen_commands(schema, output_dir, prefix):
+ blurb = ' * Schema-defined QAPI/QMP commands'