Re: [PATCH 3/3] rust: generate bindings via cbindgen
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 23, 2025, 22:01 UTC
- Message-ID
- <xmqqbjlxs2f7.fsf@gitster.g>
- In-Reply-To
- <20251023-b4-pks-rust-cbindgen-v1-3-c19b61b03127@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 9 quoted lines
> 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 <ps@pks.im> > ---
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)