]> Kevux Git Server - rit/commit
libgit-sys: introduce Rust wrapper for libgit.a
authorJosh Steadmon <steadmon@google.com>
Tue, 28 Jan 2025 22:01:38 +0000 (14:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jan 2025 22:45:47 +0000 (14:45 -0800)
commite7f8bf125c078004232e254e71b97226c4fed81b
treebc14f55bd4768731a7e47ccb3b985edd8231fcf1
parent3f8f2abe05c0aeb0ea60768d44a99261ed456d44
libgit-sys: introduce Rust wrapper for libgit.a

Introduce libgit-sys, a Rust wrapper crate that allows Rust code to call
functions in libgit.a. This initial patch defines build rules and an
interface that exposes user agent string getter functions as a proof of
concept. This library can be tested with `cargo test`. In later commits,
a higher-level library containing a more Rust-friendly interface will be
added at `contrib/libgit-rs`.

Symbols in libgit can collide with symbols from other libraries such as
libgit2. We avoid this by first exposing library symbols in
public_symbol_export.[ch]. These symbols are prepended with "libgit_" to
avoid collisions and set to visible using a visibility pragma. In
build.rs, Rust builds contrib/libgit-rs/libgit-sys/libgitpub.a, which also
contains libgit.a and other dependent libraries, with
-fvisibility=hidden to hide all symbols within those libraries that
haven't been exposed with a visibility pragma.

Co-authored-by: Kyle Lippincott <spectral@google.com>
Co-authored-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
.gitignore
Makefile
contrib/libgit-sys/Cargo.lock [new file with mode: 0644]
contrib/libgit-sys/Cargo.toml [new file with mode: 0644]
contrib/libgit-sys/README.md [new file with mode: 0644]
contrib/libgit-sys/build.rs [new file with mode: 0644]
contrib/libgit-sys/public_symbol_export.c [new file with mode: 0644]
contrib/libgit-sys/public_symbol_export.h [new file with mode: 0644]
contrib/libgit-sys/src/lib.rs [new file with mode: 0644]
t/Makefile