diff mbox series

[21/23] rust: make rustfmt optional

Message ID 20241025160209.194307-22-pbonzini@redhat.com
State New
Headers show
Series rust: fix CI + allow older versions of rustc and bindgen | expand

Commit Message

Paolo Bonzini Oct. 25, 2024, 4:02 p.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index fb0295b312c..3db4dcc8a24 100644
--- a/meson.build
+++ b/meson.build
@@ -115,6 +115,10 @@  if not bindgen.found() or bindgen.version().version_compare('<0.60.0')
   endif
 endif
 
+if have_rust
+  rustfmt = find_program('rustfmt', required: false)
+endif
+
 dtrace = not_found
 stap = not_found
 if 'dtrace' in get_option('trace_backends')
@@ -3973,6 +3977,13 @@  if have_rust
     '--allowlist-file', meson.project_source_root() + '/.*',
     '--allowlist-file', meson.project_build_root() + '/.*'
     ]
+  if not rustfmt.found()
+    if bindgen.version().version_compare('<0.65.0')
+      bindgen_args += ['--no-rustfmt-bindings']
+    else
+      bindgen_args += ['--formatter', 'none']
+    endif
+  endif
   if bindgen.version().version_compare('<0.61.0')
     # default in 0.61+
     bindgen_args += ['--size_t-is-usize']