[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 40/50] qapi: add -i/--include filename.h
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v3 40/50] qapi: add -i/--include filename.h |
Date: |
Mon, 11 Sep 2017 13:06:13 +0200 |
Add a new option to add user-specified #include lines in the generated
headers. This will help to split a schema, where one generated header
will depend on another.
Signed-off-by: Marc-André Lureau <address@hidden>
---
scripts/qapi.py | 13 +++++++++----
scripts/qapi-commands.py | 7 +++++--
scripts/qapi-event.py | 6 ++++--
scripts/qapi-introspect.py | 5 +++--
scripts/qapi-types.py | 6 ++++--
scripts/qapi-visit.py | 5 +++--
6 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 19e48bd4d2..eb4ffdc06d 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -2096,9 +2096,9 @@ def parse_command_line(extra_options='',
extra_long_options=[]):
try:
opts, args = getopt.gnu_getopt(sys.argv[1:],
- 'chp:o:' + extra_options,
- ['source', 'header', 'prefix=',
- 'output-dir='] + extra_long_options)
+ 'chp:o:i:' + extra_options,
+ ['source', 'header', 'prefix=', 'output-dir=',
+ 'include='] + extra_long_options)
except getopt.GetoptError as err:
print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err))
sys.exit(1)
@@ -2107,6 +2107,7 @@ def parse_command_line(extra_options='',
extra_long_options=[]):
prefix = ''
do_c = False
do_h = False
+ includes = []
extra_opts = []
for oa in opts:
@@ -2125,6 +2126,8 @@ def parse_command_line(extra_options='',
extra_long_options=[]):
do_c = True
elif o in ('-h', '--header'):
do_h = True
+ elif o in ('-i', '--include'):
+ includes.append(a)
else:
extra_opts.append(oa)
@@ -2137,7 +2140,9 @@ def parse_command_line(extra_options='',
extra_long_options=[]):
sys.exit(1)
fname = args[0]
- return (fname, output_dir, do_c, do_h, prefix, extra_opts)
+ includes = "\n".join(['#include "%s"' % inc for inc in includes])
+
+ return (fname, output_dir, do_c, do_h, prefix, includes, extra_opts)
#
# Generate output files with boilerplate
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 7455d2b8bb..4841f4d9a1 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -253,7 +253,8 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
self._regy += gen_register_command(name, success_response)
-(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
+(input_file, output_dir, do_c, do_h, prefix, includes, opts) = \
+ parse_command_line()
c_comment = '''
/*
@@ -305,6 +306,7 @@ fdef.write(mcgen('''
prefix=prefix))
fdecl.write(mcgen('''
+%(includes)s
#include "%(prefix)sqapi-types.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/dispatch.h"
@@ -312,7 +314,8 @@ fdecl.write(mcgen('''
void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
''',
- prefix=prefix, c_prefix=c_name(prefix, protect=False)))
+ includes=includes, prefix=prefix,
+ c_prefix=c_name(prefix, protect=False)))
schema = QAPISchema(input_file)
gen = QAPISchemaGenCommandVisitor()
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 60c6f7030d..0aba866dc8 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -171,7 +171,8 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
self._event_names.append(QAPISchemaMember(name, ifcond))
-(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
+(input_file, output_dir, do_c, do_h, prefix, includes, dummy) = \
+ parse_command_line()
c_comment = '''
/*
@@ -218,13 +219,14 @@ fdef.write(mcgen('''
prefix=prefix))
fdecl.write(mcgen('''
+%(includes)s
#include "qapi/error.h"
#include "qapi/util.h"
#include "qapi/qmp/qdict.h"
#include "%(prefix)sqapi-types.h"
''',
- prefix=prefix))
+ includes=includes, prefix=prefix))
event_enum_name = c_name(prefix + 'QAPIEvent', protect=False)
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index d6194ff702..f9abd83490 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -192,7 +192,7 @@ const QLitObject %(c_name)s = %(c_string)s;
# We normally mask them, because they're not QMP wire ABI
opt_unmask = False
-(input_file, output_dir, do_c, do_h, prefix, opts) = \
+(input_file, output_dir, do_c, do_h, prefix, includes, opts) = \
parse_command_line('u', ['unmask-non-abi-names'])
for o, a in opts:
@@ -235,10 +235,11 @@ fdef.write(mcgen('''
prefix=prefix))
fdecl.write(mcgen('''
+%(includes)s
#include "qemu/osdep.h"
#include "qapi/qmp/qlit.h"
-'''))
+''', includes=includes))
schema = QAPISchema(input_file)
gen = QAPISchemaGenIntrospectVisitor(opt_unmask)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 312685c295..2b46a7e17f 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -266,7 +266,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
# QAPISchemaGenTypeVisitor.visit_end().
do_builtins = False
-(input_file, output_dir, do_c, do_h, prefix, opts) = \
+(input_file, output_dir, do_c, do_h, prefix, includes, opts) = \
parse_command_line('b', ['builtins'])
for o, a in opts:
@@ -317,7 +317,9 @@ fdef.write(mcgen('''
fdecl.write(mcgen('''
#include "qapi/util.h"
-'''))
+%(includes)s
+''',
+ includes=includes))
schema = QAPISchema(input_file)
gen = QAPISchemaGenTypeVisitor()
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 369e1f927d..1e173d3cd7 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -338,7 +338,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
# QAPISchemaGenVisitVisitor.visit_end().
do_builtins = False
-(input_file, output_dir, do_c, do_h, prefix, opts) = \
+(input_file, output_dir, do_c, do_h, prefix, includes, opts) = \
parse_command_line('b', ['builtins'])
for o, a in opts:
@@ -387,12 +387,13 @@ fdef.write(mcgen('''
prefix=prefix))
fdecl.write(mcgen('''
+%(includes)s
#include "qapi/visitor.h"
#include "qapi/qmp/qerror.h"
#include "%(prefix)sqapi-types.h"
''',
- prefix=prefix))
+ includes=includes, prefix=prefix))
schema = QAPISchema(input_file)
gen = QAPISchemaGenVisitVisitor()
--
2.14.1.146.gd35faa819
- [Qemu-devel] [PATCH v3 32/50] qapi2texi: add 'If:' section to generated documentation, (continued)
- [Qemu-devel] [PATCH v3 32/50] qapi2texi: add 'If:' section to generated documentation, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 31/50] docs: document schema configuration, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 33/50] qapi2texi: add 'If:' condition to enum values, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 34/50] qapi2texi: add 'If:' condition to struct members, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 35/50] qapi2texi: add condition to variants, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 36/50] qapi: add conditions to VNC type/commands/events on the schema, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 37/50] qapi: add conditions to SPICE type/commands/events on the schema, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 38/50] qapi: add conditions to REPLICATION type/commands on the schema, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 39/50] qapi-commands: don't initialize command list in qmp_init_marshall(), Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 41/50] qapi: add a 'unit' pragma, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 40/50] qapi: add -i/--include filename.h,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v3 42/50] qapi: add a -u/--unit option to specify which unit to visit, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 44/50] build-sys: add a target schema, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 43/50] build-sys: move qmp-introspect per target, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 45/50] qapi: make rtc-reset-reinjection depend on TARGET_I386, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 47/50] target.json: add a note about query-cpu* not being s390x-specific, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 46/50] qapi: make s390 commands depend on TARGET_S390X, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 49/50] qapi: make query-cpu-model-expansion depend on s390 or x86, Marc-André Lureau, 2017/09/11