diff mbox series

[PoCv2,08/15] qga/rust: generate QGA QAPI sys bindings

Message ID 20201011203513.1621355-9-marcandre.lureau@redhat.com
State New
Headers show
Series Rust binding for QAPI (qemu-ga only, for now) | expand

Commit Message

Marc-André Lureau Oct. 11, 2020, 8:35 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Use qapi-gen to generate low-level C sys bindings for QAPI types,
include them to the build.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qga/Cargo.toml  |  4 ++++
 qga/lib.rs      |  1 +
 qga/meson.build | 11 +++++++++++
 qga/qapi_sys.rs |  5 +++++
 4 files changed, 21 insertions(+)
 create mode 100644 qga/qapi_sys.rs
diff mbox series

Patch

diff --git a/qga/Cargo.toml b/qga/Cargo.toml
index 50c3415ab2..9966057594 100644
--- a/qga/Cargo.toml
+++ b/qga/Cargo.toml
@@ -4,6 +4,10 @@  version = "0.1.0"
 edition = "2018"
 license = "GPLv2"
 
+[dependencies]
+common = { path = "../rust/common" }
+libc = "^0.2.76"
+
 [lib]
 path = "lib.rs"
 crate-type = ["staticlib"]
diff --git a/qga/lib.rs b/qga/lib.rs
index e69de29bb2..050a47e2a3 100644
--- a/qga/lib.rs
+++ b/qga/lib.rs
@@ -0,0 +1 @@ 
+mod qapi_sys;
diff --git a/qga/meson.build b/qga/meson.build
index 62e13a11b3..dbc8f1623b 100644
--- a/qga/meson.build
+++ b/qga/meson.build
@@ -47,10 +47,21 @@  qga_ss = qga_ss.apply(config_host, strict: false)
 
 qga_rs = declare_dependency()
 if with_rust
+  qga_qapi_rs_outputs = [
+    'qga-qapi-sys-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,
                                       'build-lib',
                                       meson.current_build_dir(),
diff --git a/qga/qapi_sys.rs b/qga/qapi_sys.rs
new file mode 100644
index 0000000000..06fc49b826
--- /dev/null
+++ b/qga/qapi_sys.rs
@@ -0,0 +1,5 @@ 
+#![allow(dead_code)]
+include!(concat!(
+    env!("MESON_BUILD_ROOT"),
+    "/qga/qga-qapi-sys-types.rs"
+));