qemu-e2k/scripts/qapi
Markus Armbruster 252dc3105f qapi: Generate separate .h, .c for each module
Our qapi-schema.json is composed of modules connected by include
directives, but the generated code is monolithic all the same: one
qapi-types.h with all the types, one qapi-visit.h with all the
visitors, and so forth.  These monolithic headers get included all
over the place.  In my "build everything" tree, adding a QAPI type
recompiles about 4800 out of 5100 objects.

We wouldn't write such monolithic headers by hand.  It stands to
reason that we shouldn't generate them, either.

Split up generated qapi-types.h to mirror the schema's modular
structure: one header per module.  Name the main module's header
qapi-types.h, and sub-module D/B.json's header D/qapi-types-B.h.

Mirror the schema's includes in the headers, so that qapi-types.h gets
you everything exactly as before.  If you need less, you can include
one or more of the sub-module headers.  To be exploited shortly.

Split up qapi-types.c, qapi-visit.h, qapi-visit.c, qmp-commands.h,
qmp-commands.c, qapi-event.h, qapi-event.c the same way.
qmp-introspect.h, qmp-introspect.c and qapi.texi remain monolithic.

The split of qmp-commands.c duplicates static helper function
qmp_marshal_output_str() in qapi-commands-char.c and
qapi-commands-misc.c.  This happens when commands returning the same
type occur in multiple modules.  Not worth avoiding.

Since I'm going to rename qapi-event.[ch] to qapi-events.[ch], and
qmp-commands.[ch] to qapi-commands.[ch], name the shards that way
already, to reduce churn.  This requires temporary hacks in
commands.py and events.py.  Similarly, c_name() must temporarily
be taught to munge '/' in common.py.  They'll go away with the rename.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180211093607.27351-23-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: declare a dummy variable in each .c file, to shut up OSX
toolchain warnings about empty .o files, including hacking c_name()]
Signed-off-by: Eric Blake <eblake@redhat.com>
2018-03-02 13:44:24 -06:00
..
__init__.py qapi-gen: New common driver for code and doc generators 2018-03-02 13:14:09 -06:00
commands.py qapi: Generate separate .h, .c for each module 2018-03-02 13:44:24 -06:00
common.py qapi: Generate separate .h, .c for each module 2018-03-02 13:44:24 -06:00
doc.py qapi: Make code-generating visitors use QAPIGen more 2018-03-02 13:14:10 -06:00
events.py qapi: Generate separate .h, .c for each module 2018-03-02 13:44:24 -06:00
introspect.py qapi: Make code-generating visitors use QAPIGen more 2018-03-02 13:14:10 -06:00
types.py qapi/types qapi/visit: Generate built-in stuff into separate files 2018-03-02 13:14:10 -06:00
visit.py qapi/types qapi/visit: Generate built-in stuff into separate files 2018-03-02 13:14:10 -06:00