[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PoCv2 08/15] qga/rust: generate QGA QAPI sys bindings
From: |
marcandre . lureau |
Subject: |
[PoCv2 08/15] qga/rust: generate QGA QAPI sys bindings |
Date: |
Mon, 12 Oct 2020 00:35:06 +0400 |
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 --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"
+));
--
2.28.0
- [PoCv2 00/15] Rust binding for QAPI (qemu-ga only, for now), marcandre . lureau, 2020/10/11
- [PoCv2 01/15] mingw: fix error __USE_MINGW_ANSI_STDIO redefined, marcandre . lureau, 2020/10/11
- [PoCv2 02/15] scripts/qapi: teach c_param_type() to return const argument type, marcandre . lureau, 2020/10/11
- [PoCv2 03/15] build-sys: add --with-rust{-target} & basic build infrastructure, marcandre . lureau, 2020/10/11
- [PoCv2 04/15] build-sys: add a cargo-wrapper script, marcandre . lureau, 2020/10/11
- [PoCv2 05/15] qga/rust: build and link an empty static library, marcandre . lureau, 2020/10/11
- [PoCv2 06/15] rust: provide a common crate for QEMU, marcandre . lureau, 2020/10/11
- [PoCv2 07/15] scripts/qapi: add Rust sys bindings generation, marcandre . lureau, 2020/10/11
- [PoCv2 08/15] qga/rust: generate QGA QAPI sys bindings,
marcandre . lureau <=
- [PoCv2 09/15] scripts/qapi: add generation of Rust bindings for types, marcandre . lureau, 2020/10/11
- [PoCv2 10/15] qga/rust: build Rust types, marcandre . lureau, 2020/10/11
- [PoCv2 11/15] qga: add qmp! macro helper, marcandre . lureau, 2020/10/11
- [PoCv2 12/15] qga: implement get-host-name in Rust, marcandre . lureau, 2020/10/11
- [PoCv2 13/15] qga: implement {get,set}-vcpus in Rust, marcandre . lureau, 2020/10/11
- [PoCv2 14/15] travis: add Rust, marcandre . lureau, 2020/10/11
- [PoCv2 15/15] rust: use vendored-sources, marcandre . lureau, 2020/10/11
- Re: [PoCv2 00/15] Rust binding for QAPI (qemu-ga only, for now), no-reply, 2020/10/11