[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PoCv2 05/15] qga/rust: build and link an empty static library
From: |
marcandre . lureau |
Subject: |
[PoCv2 05/15] qga/rust: build and link an empty static library |
Date: |
Mon, 12 Oct 2020 00:35:03 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Meson doesn't integrate very smoothly with Cargo. Use the cargo-wrapper
script as a custom_target() always stale to build the Rust code. The
"build-lib" command will produce a static library in the meson expected
output directory, as well as link flags that must be employed to do the
final link.
Those link flags can't be queried during configure time (Cargo doesn't
have a user-queriable configure step), so we pass them to the linker
thanks to @file argument support at build time.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
Cargo.toml | 2 +-
qga/Cargo.toml | 9 +++++++++
qga/lib.rs | 0
qga/meson.build | 18 +++++++++++++++++-
4 files changed, 27 insertions(+), 2 deletions(-)
create mode 100644 qga/Cargo.toml
create mode 100644 qga/lib.rs
diff --git a/Cargo.toml b/Cargo.toml
index c4b464ff15..e69b04200f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,2 +1,2 @@
[workspace]
-members = []
+members = ["qga"]
diff --git a/qga/Cargo.toml b/qga/Cargo.toml
new file mode 100644
index 0000000000..50c3415ab2
--- /dev/null
+++ b/qga/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "qga"
+version = "0.1.0"
+edition = "2018"
+license = "GPLv2"
+
+[lib]
+path = "lib.rs"
+crate-type = ["staticlib"]
diff --git a/qga/lib.rs b/qga/lib.rs
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/qga/meson.build b/qga/meson.build
index cd08bd953a..62e13a11b3 100644
--- a/qga/meson.build
+++ b/qga/meson.build
@@ -45,9 +45,25 @@ qga_ss.add(when: 'CONFIG_WIN32', if_true: files(
qga_ss = qga_ss.apply(config_host, strict: false)
+qga_rs = declare_dependency()
+if with_rust
+ cargo_qga = custom_target('cargo-qga',
+ build_by_default: true,
+ output: ['libqga.args', 'libqga.a'],
+ build_always_stale: true,
+ command: [cargo_wrapper,
+ 'build-lib',
+ meson.current_build_dir(),
+ meson.current_source_dir(),
+ meson.build_root(),
+ rs_build_type,
+ rs_target_triple])
+ qga_rs = declare_dependency(link_args: '@' + cargo_qga.full_path(), sources:
cargo_qga)
+endif
+
qga = executable('qemu-ga', qga_ss.sources(),
link_args: config_host['LIBS_QGA'].split(),
- dependencies: [qemuutil, libudev],
+ dependencies: [qemuutil, libudev, qga_rs],
install: true)
all_qga = [qga]
--
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 <=
- [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, 2020/10/11
- [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