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.
This series' basic idea is to split up generated headers to mirror the
schema's modular structure: one header per module. That way, you can
include just what you need.
The compile-time improvements can be massive. Before this series, any
QAPI schema change recompiles some 4800 out of 5100 objects in my
"build everything" tree. Afterwards, adding a type to
qapi/migration.json recompiles a bit over 100, and a documentation
change no longer recompiles anything.
Related: Marc-André's 'unit' pragma proposal. That's a different way
to split off parts of the generated code, motivated by the desire to
use poisoned identifiers such as TARGET_I386. I noted in my review of
v3 that I "can either accept it, or come up with a better solution."
This is my attempt at a better solution. It's a bit more ambitious,
and thus more useful (I hope). The pragma has one theoretical
advantage, though: you can modularize the generated output in
different ways than the input. The patches using don't do that,
however.