[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 24/32] qga/rust: generate QGA QAPI types FFI bindings
From: |
marcandre . lureau |
Subject: |
[RFC v3 24/32] qga/rust: generate QGA QAPI types FFI bindings |
Date: |
Tue, 7 Sep 2021 16:19:35 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Use qapi-gen to generate low-level C FFI bindings for QAPI types,
include them to the build.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
Cargo.lock | 3 +++
qga/Cargo.toml | 3 +++
qga/lib.rs | 1 +
qga/meson.build | 11 +++++++++++
qga/qapi_ffi.rs | 8 ++++++++
5 files changed, 26 insertions(+)
create mode 100644 qga/qapi_ffi.rs
diff --git a/Cargo.lock b/Cargo.lock
index 2f5b202605..ad5bb47762 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -72,3 +72,6 @@ dependencies = [
[[package]]
name = "qga"
version = "0.1.0"
+dependencies = [
+ "common",
+]
diff --git a/qga/Cargo.toml b/qga/Cargo.toml
index a3bffd1fec..807acc947e 100644
--- a/qga/Cargo.toml
+++ b/qga/Cargo.toml
@@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2018"
publish = false
+[dependencies]
+common = { path = "../rust/common" }
+
[lib]
path = "lib.rs"
crate-type = ["staticlib"]
diff --git a/qga/lib.rs b/qga/lib.rs
index e69de29bb2..17cf43a5e9 100644
--- a/qga/lib.rs
+++ b/qga/lib.rs
@@ -0,0 +1 @@
+mod qapi_ffi;
diff --git a/qga/meson.build b/qga/meson.build
index d272892ced..88d59bef0c 100644
--- a/qga/meson.build
+++ b/qga/meson.build
@@ -56,10 +56,21 @@ qga_ss = qga_ss.apply(config_host, strict: false)
qga_rs = declare_dependency()
if with_rust
+ qga_qapi_rs_outputs = [
+ 'qga-qapi-ffi-types.rs',
+ ]
+
+ qapi_gen_rs_files = custom_target('QGA QAPI Rust bindings',
+ output: qga_qapi_rs_outputs,
+ input: 'qapi-schema.json',
+ command: [ qapi_gen, '-r', '-o', 'qga',
'-p', 'qga-', '@INPUT0@' ],
+ depend_files: qapi_gen_depends)
+
cargo_qga = custom_target('cargo-qga',
build_by_default: true,
output: ['libqga.args', 'libqga.a'],
build_always_stale: true,
+ depends: [qapi_gen_rs_files],
command: [cargo_wrapper,
meson.current_build_dir(),
meson.current_source_dir(),
diff --git a/qga/qapi_ffi.rs b/qga/qapi_ffi.rs
new file mode 100644
index 0000000000..1f4ade9318
--- /dev/null
+++ b/qga/qapi_ffi.rs
@@ -0,0 +1,8 @@
+#![allow(dead_code)]
+
+use common::libc;
+
+include!(concat!(
+ env!("MESON_BUILD_ROOT"),
+ "/qga/qga-qapi-ffi-types.rs"
+));
--
2.33.0.113.g6c40894d24
- Re: [RFC v3 14/32] scripts/qapi: add QAPISchemaIfCond.rsgen(), (continued)
- [RFC v3 15/32] scripts/qapi: strip trailing whitespaces, marcandre . lureau, 2021/09/07
- [RFC v3 16/32] scripts/qapi: add Rust FFI bindings generation, marcandre . lureau, 2021/09/07
- [RFC v3 17/32] scripts/qapi: learn to generate ABI dump for Rust FFI, marcandre . lureau, 2021/09/07
- [RFC v3 18/32] tests: generate Rust bindings, marcandre . lureau, 2021/09/07
- [RFC v3 19/32] tests: check Rust and C CABI diffs, marcandre . lureau, 2021/09/07
- [RFC v3 20/32] scripts/qapi: generate high-level Rust bindings, marcandre . lureau, 2021/09/07
- [RFC v3 22/32] qga: build qapi-cabi binary (ABI from C), marcandre . lureau, 2021/09/07
- [RFC v3 21/32] tests/rust: build a common library, checking bindings compile, marcandre . lureau, 2021/09/07
- [RFC v3 23/32] qga/rust: build and link an empty static library, marcandre . lureau, 2021/09/07
- [RFC v3 24/32] qga/rust: generate QGA QAPI types FFI bindings,
marcandre . lureau <=
- [RFC v3 25/32] qga/rust: build a qga-cabi-rs executable (ABI from Rust), marcandre . lureau, 2021/09/07
- [RFC v3 26/32] qga/rust: check the Rust C binding, marcandre . lureau, 2021/09/07
- [RFC v3 27/32] qga/rust: build high-level Rust QAPI types, marcandre . lureau, 2021/09/07
- [RFC v3 28/32] qga/rust: implement get-host-name in Rust (example), marcandre . lureau, 2021/09/07
- [RFC v3 29/32] qga/rust: implement {get,set}-vcpus in Rust (example), marcandre . lureau, 2021/09/07
- [RFC v3 30/32] tests/vm: add Rust to FreeBSD VM, marcandre . lureau, 2021/09/07
- [RFC v3 31/32] tests/vm: bump fedora VM to f32, marcandre . lureau, 2021/09/07
- [RFC v3 32/32] tests/vm: add Rust to Fedora, marcandre . lureau, 2021/09/07
- Re: [RFC v3 00/32] Rust binding for QAPI and qemu-ga QMP handler examples, Markus Armbruster, 2021/09/08