Subject: Re: [PATCH 3/3] rust: generate bindings via cbindgen

From: Junio C Hamano <[email-masked]>
Date: Thu, 23 Oct 2025 15:01:32 -0700

Patrick Steinhardt <[email-masked]> writes:

> An initial version instead included the bindings in "varint.h". But that
> would cause us to recompile all dependents of "varint.h" every time the
> signatures of exported Rust functions change. So instead, we now include
> it in "varint.c" and compile that file unconditionally again.
>
> Adapt our CI to install cbindgen(1) accordingly.
>
> Signed-off-by: Patrick Steinhardt <[email-masked]>
> ---

I am debating myself if we want a patch like this.  I tend to prefer
"make clean" not to be too specific to the build options used to
leave crufts.

 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git i/Makefile w/Makefile
index 59e5a2c61c..9b673865e5 100644
--- i/Makefile
+++ w/Makefile
@@ -1558,12 +1558,13 @@ endif
 ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND)
 ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)
 
+# allow "make WITH_RUST=Yes && make clean" to discard it
+C_BINDINGS = c-bindings.h
+
 ifdef WITH_RUST
 BASIC_CFLAGS += -DWITH_RUST
 GITLIBS += $(RUST_LIB)
 
-C_BINDINGS = c-bindings.h
-
 GENERATED_H += $(C_BINDINGS)
 
 $(C_BINDINGS): cbindgen.toml $(RUST_SOURCES)