Hi, The thrid and last part (of "[PATCH v2 00/54] qapi: add #if pre-processor conditions to generated code") is about adding schema conditions based on the target.
For now, the qapi code is compiled in common objects (common to all targets). This makes it impossible to add #if TARGET_ARM for example. The patch "RFC: qapi: learn to split the schema by 'top-unit'" proposes to split the schema by "top-unit", so that generated code can be built either in common objects or per-target. That patch is a bit rough, I would like to get some feedback about the approach before trying to improve it. The following patches demonstrate usage of target-based #if conditions, and getting rid of the qmp_unregister_command() hack. Marc-André Lureau (13): build-sys: move qmp-introspect per target qapi-commands: don't initialize command list in qmp_init_marshall() qapi-commands: rename init_marshal() to register_commands() RFC: qapi: learn to split the schema by 'top-unit' qapi: add a top-unit 'target' schema qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386 qapi: make s390 commands depend on TARGET_S390X target.json: add a note about query-cpu* not being s390x-specific qapi: make query-gic-capabilities depend on TARGET_ARM qapi: make query-cpu-model-expansion depend on s390 or x86 qapi: make query-cpu-definitions depend on specific targets qapi: remove qmp_unregister_command() qapi: move RTC_CHANGE to the target schema qapi/misc.json | 478 ---------------------- qapi/qapi-schema.json | 1 + qapi/target.json | 516 ++++++++++++++++++++++++ scripts/qapi/commands.py | 28 +- scripts/qapi/common.py | 105 ++++- scripts/qapi/events.py | 37 +- scripts/qapi/types.py | 8 +- scripts/qapi/visit.py | 8 +- include/qapi/qmp-event.h | 4 + include/qapi/qmp/dispatch.h | 1 - include/sysemu/arch_init.h | 11 - target/i386/sev_i386.h | 2 +- hw/ppc/spapr_rtc.c | 2 +- hw/s390x/s390-skeys.c | 2 +- hw/timer/mc146818rtc.c | 4 +- monitor.c | 306 +++++++------- qapi/qmp-event.c | 11 + qapi/qmp-registry.c | 8 - qga/main.c | 3 +- qmp.c | 26 -- stubs/arch-query-cpu-def.c | 11 - stubs/arch-query-cpu-model-baseline.c | 13 - stubs/arch-query-cpu-model-comparison.c | 13 - stubs/arch-query-cpu-model-expansion.c | 13 - target/arm/helper.c | 3 +- target/arm/monitor.c | 2 +- target/i386/cpu.c | 6 +- target/ppc/translate_init.inc.c | 3 +- target/s390x/cpu_models.c | 9 +- tests/test-qmp-cmds.c | 3 +- tests/test-qobject-input-visitor.c | 1 - Makefile | 7 +- Makefile.objs | 2 - Makefile.target | 4 + docs/devel/qapi-code-gen.txt | 6 +- stubs/Makefile.objs | 4 - 36 files changed, 851 insertions(+), 810 deletions(-) create mode 100644 qapi/target.json delete mode 100644 stubs/arch-query-cpu-def.c delete mode 100644 stubs/arch-query-cpu-model-baseline.c delete mode 100644 stubs/arch-query-cpu-model-comparison.c delete mode 100644 stubs/arch-query-cpu-model-expansion.c -- 2.20.0