rust: make rustfmt optional
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 18 Oct 2024 17:23:00 +0000 (19:23 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 6 Nov 2024 16:12:17 +0000 (17:12 +0100)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
meson.build

index 11958c67b5f9859175d6b006c67de97138a8f59d..dfa37e0caa9cc17b033b57bd23f747972c132a0a 100644 (file)
@@ -117,6 +117,10 @@ if have_rust
   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')
@@ -3995,6 +3999,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']