[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 21/32] tests/rust: build a common library, checking bindings com
From: |
marcandre . lureau |
Subject: |
[RFC v3 21/32] tests/rust: build a common library, checking bindings compile |
Date: |
Tue, 7 Sep 2021 16:19:32 +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>
---
tests/Cargo.toml | 4 ++++
tests/lib.rs | 2 ++
tests/meson.build | 20 +++++++++++++++++++-
tests/qapi.rs | 11 +++++++++++
4 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 tests/lib.rs
create mode 100644 tests/qapi.rs
diff --git a/tests/Cargo.toml b/tests/Cargo.toml
index 7a4f6060b1..8a014dff89 100644
--- a/tests/Cargo.toml
+++ b/tests/Cargo.toml
@@ -7,6 +7,10 @@ publish = false
[dependencies]
common = { path = "../rust/common" }
+[lib]
+path = "lib.rs"
+crate-type = ["staticlib"]
+
[[bin]]
name = "qapi-cabi-rs"
path = "qapi-cabi.rs"
diff --git a/tests/lib.rs b/tests/lib.rs
new file mode 100644
index 0000000000..e6fdf60a55
--- /dev/null
+++ b/tests/lib.rs
@@ -0,0 +1,2 @@
+mod qapi_ffi;
+mod qapi;
diff --git a/tests/meson.build b/tests/meson.build
index f9af42caba..09aa2bdf55 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -45,7 +45,10 @@ test_qapi_files = custom_target('Test QAPI files',
depend_files: qapi_gen_depends)
if with_rust
- test_qapi_rs_outputs = ['test-qapi-ffi-types.rs']
+ test_qapi_rs_outputs = [
+ 'test-qapi-ffi-types.rs',
+ 'test-qapi-types.rs',
+ ]
test_qapi_rs = custom_target('Test QAPI Rust binding',
output: test_qapi_rs_outputs,
input: test_qapi_inputs,
@@ -65,6 +68,21 @@ if with_rust
'build-bin',
'qapi-cabi-rs',
'--', '--cfg', 'QAPI_CABI'])
+ libtest_rs = custom_target('Test Rust library',
+ build_by_default: true,
+ output: ['libqemu_tests.args', 'libqemu_tests.a'],
+ build_always_stale: true,
+ depends: [test_qapi_rs],
+ command: [cargo_wrapper,
+ meson.current_build_dir(),
+ meson.current_source_dir(),
+ meson.build_root(),
+ rs_build_type,
+ rust_target_triple,
+ 'build-lib'])
+ libtest_rs = declare_dependency(
+ link_args: '@' + libtest_rs[0].full_path(),
+ sources: libtest_rs)
endif
# meson doesn't like generated output in other directories
diff --git a/tests/qapi.rs b/tests/qapi.rs
new file mode 100644
index 0000000000..93e3e714e7
--- /dev/null
+++ b/tests/qapi.rs
@@ -0,0 +1,11 @@
+#![allow(dead_code)]
+#![allow(non_camel_case_types)]
+
+use common::*;
+
+new_ptr!();
+
+include!(concat!(
+ env!("MESON_BUILD_ROOT"),
+ "/tests/test-qapi-types.rs"
+));
--
2.33.0.113.g6c40894d24
- [RFC v3 14/32] scripts/qapi: add QAPISchemaIfCond.rsgen(), (continued)
- [RFC v3 14/32] scripts/qapi: add QAPISchemaIfCond.rsgen(), marcandre . lureau, 2021/09/07
- [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 <=
- [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, 2021/09/07
- [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