On 17/2/25 14:49, Daniel P. Berrangé wrote:
The 'qapi.backend.QAPIBackend' class defines an API contract for
code generators. The current generator is put into a new class
'qapi.backend.QAPICBackend' and made to be the default impl.

A custom generator can be requested using the '-k' arg which takes
a fully qualified python class name

    qapi-gen.py -k the.python.module.QAPIMyBackend

Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>
---

This is an impl of the idea I mentioned at:

    https://lists.nongnu.org/archive/html/qemu-devel/2025-02/msg03475.html

With this change, it is possible for the Go generator code to live
outside of qemu.git, invoked using:

   $ PYTHONPATH=/path/to/qemu.git/scripts \
     python /path/to/qemu.git/scripts/qapi-gen.py \
       -o somedir \
       -k qapi.golang.golang.QAPIGoBackend \
       /path/to/qemu.git/qga/qapi-schema.json

The external app could just expect qemu.git to be checkedout somewhere
convenient, or could use a git submodule to reference it.

  scripts/qapi/backend.py | 96 +++++++++++++++++++++++++++++++++++++++++
  scripts/qapi/main.py    | 65 ++++++++--------------------
  2 files changed, 113 insertions(+), 48 deletions(-)
  create mode 100644 scripts/qapi/backend.py

Good idea.

Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>


Reply via email to