diff mbox series

[02/11] meson: Add rust_block_ss and link tools with it

Message ID 20250211214328.640374-3-kwolf@redhat.com (mailing list archive)
State New
Headers show
Series rust/block: Add minimal block driver bindings | expand

Commit Message

Kevin Wolf Feb. 11, 2025, 9:43 p.m. UTC
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 meson.build                | 36 ++++++++++++++++++++++++++++++++----
 storage-daemon/meson.build |  2 +-
 2 files changed, 33 insertions(+), 5 deletions(-)

Comments

Philippe Mathieu-Daudé Feb. 12, 2025, 7:38 a.m. UTC | #1
On 11/2/25 22:43, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   meson.build                | 36 ++++++++++++++++++++++++++++++++----
>   storage-daemon/meson.build |  2 +-
>   2 files changed, 33 insertions(+), 5 deletions(-)


>     if have_rust and target_type == 'system'
> -    target_rust = rust_devices_ss.apply(config_target, strict: false)
> +    target_rust_ss = ss.source_set()
> +    target_rust_ss.add_all(rust_block_ss)
> +    target_rust_ss.add_all(rust_devices_ss)
> +
> +    target_rust = target_rust_ss.apply(config_target, strict: false)
>       crates = []
>       foreach dep : target_rust.dependencies()
>         crates += dep.get_variable('crate')
> @@ -4349,15 +4354,38 @@ if xkbcommon.found()
>   endif
>   
>   if have_tools
> +  tools_deps = []

To simplify, we can likely start with:

      tools_deps = [qemuutil]

Maybe clearer to introduce tools_deps[] as a preliminary
patch although.
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index 1f26801b69..30aae6b3c3 100644
--- a/meson.build
+++ b/meson.build
@@ -3640,6 +3640,7 @@  qom_ss = ss.source_set()
 system_ss = ss.source_set()
 specific_fuzz_ss = ss.source_set()
 specific_ss = ss.source_set()
+rust_block_ss = ss.source_set()
 rust_devices_ss = ss.source_set()
 stub_ss = ss.source_set()
 trace_ss = ss.source_set()
@@ -4209,7 +4210,11 @@  foreach target : target_dirs
   arch_deps += target_specific.dependencies()
 
   if have_rust and target_type == 'system'
-    target_rust = rust_devices_ss.apply(config_target, strict: false)
+    target_rust_ss = ss.source_set()
+    target_rust_ss.add_all(rust_block_ss)
+    target_rust_ss.add_all(rust_devices_ss)
+
+    target_rust = target_rust_ss.apply(config_target, strict: false)
     crates = []
     foreach dep : target_rust.dependencies()
       crates += dep.get_variable('crate')
@@ -4349,15 +4354,38 @@  if xkbcommon.found()
 endif
 
 if have_tools
+  tools_deps = []
+  if have_rust
+    tools_rust = rust_block_ss.apply({})
+    crates = []
+    foreach dep : tools_rust.dependencies()
+      crates += dep.get_variable('crate')
+    endforeach
+    if crates.length() > 0
+      rlib_rs = custom_target('rust_tools.rs',
+                              output: 'rust_tools.rs',
+                              command: [rust_root_crate, crates],
+                              capture: true,
+                              build_by_default: true,
+                              build_always_stale: true)
+      rlib = static_library('rust_tools',
+                            rlib_rs,
+                            dependencies: tools_rust.dependencies(),
+                            override_options: ['rust_std=2021', 'build.rust_std=2021'],
+                            rust_abi: 'c')
+      tools_deps += declare_dependency(link_whole: [rlib])
+    endif
+  endif
+
   qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
              link_args: '@block.syms', link_depends: block_syms,
-             dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
+             dependencies: tools_deps + [authz, block, crypto, io, qom, qemuutil], install: true)
   qemu_io = executable('qemu-io', files('qemu-io.c'),
              link_args: '@block.syms', link_depends: block_syms,
-             dependencies: [block, qemuutil], install: true)
+             dependencies: tools_deps + [block, qemuutil], install: true)
   qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
                link_args: '@block.syms', link_depends: block_syms,
-               dependencies: [blockdev, qemuutil, selinux],
+               dependencies: tools_deps + [blockdev, qemuutil, selinux],
                install: true)
 
   subdir('storage-daemon')
diff --git a/storage-daemon/meson.build b/storage-daemon/meson.build
index 5e61a9d1bd..92bc2e0cba 100644
--- a/storage-daemon/meson.build
+++ b/storage-daemon/meson.build
@@ -9,6 +9,6 @@  if have_tools
   qsd = executable('qemu-storage-daemon',
                    qsd_ss.sources(),
                    link_args: '@block.syms', link_depends: block_syms,
-                   dependencies: qsd_ss.dependencies(),
+                   dependencies: tools_deps + qsd_ss.dependencies(),
                    install: true)
 endif