Closed weihanglo closed 1 year ago
This is spun off from https://github.com/rust-lang/git2-rs/pull/939 with more contexts.
In addition, we may want to build a convention for this kind of *-sys
. Some ideas people have shared with me:
CARGO_BUILD_NO_VENDOR
which if set prevents any vendoringCARGO_BUILD_MYCRATE_NO_VENDOR
which if set prevents vendoring in mycrate.no-vendor
feature in sys crates trumps vendored
feature.More motivations why this is something we want:
vendored
feature. And there is no way to turn it off.1.6.4..1.7.0
and it silently goes vendoring if nothing found. We may want an explicit error like "your system needs a newer libgit2 to proceed".OK, sorry about the delay. Can you rebase and fix the conflicts?
Thanks for the review. Updated. Let me know if you have any concern.
Specify
LIBGIT2_NO_VENDOR
to force to use system libgit2.Due to the additive nature of Cargo features, if some crate in the dependency graph activates
vendored
feature, there is no way to revert it back. This env var serves as a workaround for this purpose.An alternative is having
no_vendored
feature. We still need to modifybuild.rs
to make bothvendored
andno_vendored
play nice with each other (or bail out as they are mutual-exclusive). However, there is no way to activate a Cargo feature via environment variable (see rust-lang/cargo#4829). Altering environment variables may be the only way to interact with some external build systems.It is also pretty common that people don't want to vendor anything and rather to see the build fail than vendoring.
Some prior arts:
OPENSSL_NO_VENDOR
inopenssl
crate, which serves the exact purpose ofLIBGIT2_NO_VENDOR
^1.ssh2
has a similarLIBSSH2_SYS_USE_PKG_CONFIG
, but it doesn't force to do so. It still falls back to vendored lib ^2.curl
has a featureforce-system-lib-on-osx
to trump all others features. It was created primarily for Rust releases ^3.