diff mbox series

[v2,13/14] rust: make rustfmt optional

Message ID 20241022100956.196657-14-pbonzini@redhat.com (mailing list archive)
State New
Headers show
Series rust: allow older versions of rustc and bindgen | expand

Commit Message

Paolo Bonzini Oct. 22, 2024, 10:09 a.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 d78afb79d67..5e3501750a1 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']