[PATCH v3 17/19] rust/util: build QAPI types
Paolo Bonzini <[email protected]> Tue, 26 May 2026 19:56:16 +0200
| Newsgroups | org.nongnu.qemu-rust,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Marc-André Lureau <[email protected]> Signed-off-by: Marc-André Lureau <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> --- qapi/meson.build | 9 +++++++++ rust/Cargo.lock | 1 + rust/Cargo.toml | 2 +- rust/util/Cargo.toml | 1 + rust/util/meson.build | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/qapi/meson.build b/qapi/meson.build index a46269b5a0c..a019ec19db1 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -130,3 +130,12 @@ foreach output : qapi_outputs util_ss.add(qapi_files[i]) i = i + 1 endforeach + +# TODO: build together with the other files, perhaps when Rust is not +# optional and/or the Rust backend is complete (currently lacking +# commands, events, modules) +qapi_rs_files = custom_target('QAPI Rust', + output: 'qapi-types.rs', + input: [ files('qapi-schema.json') ], + command: [ qapi_gen, '-o', 'qapi', '-b', '@INPUT0@', '-B', 'qapi.backend.QAPIRsBackend' ], + depend_files: [ qapi_inputs, qapi_gen_depends ]) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b9e8636b8bc..c73f037d689 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -514,6 +514,7 @@ dependencies = [ "glib-sys", "libc", "serde", + "serde_derive", "util-sys", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index fe491f3aba6..15296ac8636 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -20,7 +20,7 @@ anyhow = "~1.0" foreign = "~0.3.1" libc = "0.2.162" glib-sys = { version = "0.21.2", features = ["v2_66"] } -serde = "1.0.226" +serde = { version = "1.0.226", features = ["derive"] } serde_derive = "1.0.226" [workspace.lints.rust] diff --git a/rust/util/Cargo.toml b/rust/util/Cargo.toml index 0a0400278f3..069ab167e87 100644 --- a/rust/util/Cargo.toml +++ b/rust/util/Cargo.toml @@ -18,6 +18,7 @@ foreign = { workspace = true } glib-sys = { workspace = true } libc = { workspace = true } serde = { workspace = true } +serde_derive = { workspace = true } common = { path = "../common" } util-sys = { path = "../bindings/util-sys" } diff --git a/rust/util/meson.build b/rust/util/meson.build index a8d9978e1a9..3edd8245bfc 100644 --- a/rust/util/meson.build +++ b/rust/util/meson.build @@ -18,3 +18,20 @@ rust.doctest('rust-util-rs-doctests', dependencies: util_rs, suite: ['doc', 'rust'] ) + +_qapi_cfg = run_command(rustc_args, + '--no-strict-cfg', + '--config-headers', config_host_h, + capture: true, check: true).stdout().strip().splitlines() + +_qapi_rs = static_library( + 'qapi', + qapi_rs_files, + rust_args: _qapi_cfg, + override_options: ['rust_std=2021', 'build.rust_std=2021'], + rust_abi: 'rust', + link_with: [_util_rs], + dependencies: [common_rs, serde_rs], +) + +qapi_rs = declare_dependency(link_with: [_qapi_rs]) -- 2.54.0