@@ -2,3 +2,17 @@ subdir('qemu-api-macros')
subdir('qemu-api')
subdir('hw')
+
+cargo = find_program('cargo')
+
+run_target('clippy',
+ command: [config_host['MESON'], 'devenv',
+ '--workdir', '@CURRENT_SOURCE_DIR@',
+ cargo, 'clippy', '--tests'],
+ depends: bindings_rs)
+
+run_target('rustfmt',
+ command: [config_host['MESON'], 'devenv',
+ '--workdir', '@CURRENT_SOURCE_DIR@',
+ cargo, 'fmt'],
+ depends: bindings_rs)
@@ -15,8 +15,12 @@ fn main() {
let file = format!("{}/bindings.rs.inc", path);
if !Path::new(&file).exists() {
panic!(concat!(
- "No generated C bindings found! If you want to run `cargo`, start a subshell\n",
- "with `meson devenv`, or point MESON_BUILD_ROOT to the top of the build tree."
+ "\n",
+ " No generated C bindings found! To run clippy or rustfmt, you can use\n",
+ " `make clippy` or `make rustfmt`.\n",
+ "\n",
+ " For other uses of `cargo`, start a subshell with `meson devenv`, or\n",
+ " point MESON_BUILD_ROOT to the top of the build tree."
));
}
Abstract common invocations of "cargo", that do not require copying the generated bindgen file or setting up MESON_BUILD_ROOT. In the future these could also do completely without cargo and invoke the underlying programs directly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- rust/meson.build | 14 ++++++++++++++ rust/qemu-api/build.rs | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)