From db945aec83ef0ca9515725d30afd0a9e9fe199d0 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 3 Sep 2025 08:57:48 -0600 Subject: [PATCH] rust: bindgen requires rustfmt Bindgen will use rustfmt after generating the bindings, but this will fail if rustfmt is not installed. Only run bindgen if rustfmt is installed. --- configure.ac | 5 ++++- rust/Makefile.am | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index afe93bd8fa..fb19c26922 100644 --- a/configure.ac +++ b/configure.ac @@ -2178,6 +2178,9 @@ fi AC_SUBST(rust_vendor_comment) AM_CONDITIONAL([HAVE_RUST_VENDOR], [test "x$have_rust_vendor" = "xyes"]) +# Bindgen requires rustfmt. + AC_PATH_PROG([RUSTFMT], [rustfmt], [no]) + # Check for bindgen AC_PATH_PROG([BINDGEN], [bindgen], [no]) if test "x$BINDGEN" != "xno"; then @@ -2194,7 +2197,7 @@ fi BINDGEN="no" fi fi - AM_CONDITIONAL([HAVE_BINDGEN], [test "x$BINDGEN" != "xno"]) + AM_CONDITIONAL([HAVE_BINDGEN], [test "x$BINDGEN" != "xno" -a "x$RUSTFMT" != "xno"]) have_rust_headers="no" AC_MSG_CHECKING(for $srcdir/rust/dist/rust-bindings.h) diff --git a/rust/Makefile.am b/rust/Makefile.am index 49104786ae..b4c33d74bc 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -119,7 +119,7 @@ if HAVE_BINDGEN echo "Not checking bindings for out of tree build"; \ fi else - @echo "Unable to check bindgen bindings: bindgen not found" + @echo "Unable to check bindgen bindings: bindgen or rustfmt not found" endif check: @@ -165,7 +165,7 @@ if HAVE_BINDGEN cat sys/src/jsonbuilder.rs.tmp >> sys/src/jsonbuilder.rs rm -f sys/src/jsonbuilder.rs.tmp else - @echo "error: bindgen not installed, can't update bindings" + @echo "error: bindgen or rustfmt not installed, can't update bindings" exit 1 endif