rust-lang / git2-rs

libgit2 bindings for Rust
https://docs.rs/git2
Apache License 2.0
1.69k stars 387 forks source link

build: `LIBGIT2_NO_VENDOR` to force to use system libgit2 #966

Closed weihanglo closed 1 year ago

weihanglo commented 1 year ago

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 modify build.rs to make both vendored and no_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:

weihanglo commented 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:

weihanglo commented 1 year ago

More motivations why this is something we want:

ehuss commented 1 year ago

OK, sorry about the delay. Can you rebase and fix the conflicts?

weihanglo commented 1 year ago

Thanks for the review. Updated. Let me know if you have any concern.