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>
This commit is contained in:

committed by
Junio C Hamano

parent
3f8f2abe05
commit
e7f8bf125c
8
contrib/libgit-sys/public_symbol_export.h
Normal file
8
contrib/libgit-sys/public_symbol_export.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef PUBLIC_SYMBOL_EXPORT_H
|
||||
#define PUBLIC_SYMBOL_EXPORT_H
|
||||
|
||||
const char *libgit_user_agent(void);
|
||||
|
||||
const char *libgit_user_agent_sanitized(void);
|
||||
|
||||
#endif /* PUBLIC_SYMBOL_EXPORT_H */
|
Reference in New Issue
Block a user