Skip to content

Commit

Permalink
Add vendored feature (#739)
Browse files Browse the repository at this point in the history
As per #721, some consumers may
prefer to build `libgit2` themselves to simplify distribution.

To test the vendored version, you can run:

```
cargo build --features vendored-libgit2`
```

That being said, the test `branch::tests::name_is_valid` fails on macOS. This
test is currently broken as per
#721 (comment)
  • Loading branch information
arxanas authored Aug 27, 2021
1 parent 6db8f4e commit 97091c3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ unstable = []
default = ["ssh", "https", "ssh_key_from_memory"]
ssh = ["libgit2-sys/ssh"]
https = ["libgit2-sys/https", "openssl-sys", "openssl-probe"]
vendored-libgit2 = ["libgit2-sys/vendored"]
vendored-openssl = ["openssl-sys/vendored", "libgit2-sys/vendored-openssl"]
ssh_key_from_memory = ["libgit2-sys/ssh_key_from_memory"]
zlib-ng-compat = ["libgit2-sys/zlib-ng-compat"]
Expand Down
1 change: 1 addition & 0 deletions libgit2-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ openssl-sys = { version = "0.9", optional = true }
ssh = ["libssh2-sys"]
https = ["openssl-sys"]
ssh_key_from_memory = []
vendored = []
vendored-openssl = ["openssl-sys/vendored"]
# Cargo does not support requiring features on an optional dependency without
# requiring the dependency. Rather than introduce additional complexity, we
Expand Down
4 changes: 3 additions & 1 deletion libgit2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ use std::process::Command;
fn main() {
let https = env::var("CARGO_FEATURE_HTTPS").is_ok();
let ssh = env::var("CARGO_FEATURE_SSH").is_ok();
let vendored = env::var("CARGO_FEATURE_VENDORED").is_ok();
let zlib_ng_compat = env::var("CARGO_FEATURE_ZLIB_NG_COMPAT").is_ok();

// To use zlib-ng in zlib-compat mode, we have to build libgit2 ourselves.
if !zlib_ng_compat {
let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat;
if try_to_use_system_libgit2 {
let mut cfg = pkg_config::Config::new();
if let Ok(lib) = cfg.atleast_version("1.1.0").probe("libgit2") {
for include in &lib.include_paths {
Expand Down

0 comments on commit 97091c3

Please sign in to comment.