Skip to content

Commit 97091c3

Browse files
authored
Add vendored feature (#739)
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)
1 parent 6db8f4e commit 97091c3

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ unstable = []
3838
default = ["ssh", "https", "ssh_key_from_memory"]
3939
ssh = ["libgit2-sys/ssh"]
4040
https = ["libgit2-sys/https", "openssl-sys", "openssl-probe"]
41+
vendored-libgit2 = ["libgit2-sys/vendored"]
4142
vendored-openssl = ["openssl-sys/vendored", "libgit2-sys/vendored-openssl"]
4243
ssh_key_from_memory = ["libgit2-sys/ssh_key_from_memory"]
4344
zlib-ng-compat = ["libgit2-sys/zlib-ng-compat"]

libgit2-sys/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ openssl-sys = { version = "0.9", optional = true }
3636
ssh = ["libssh2-sys"]
3737
https = ["openssl-sys"]
3838
ssh_key_from_memory = []
39+
vendored = []
3940
vendored-openssl = ["openssl-sys/vendored"]
4041
# Cargo does not support requiring features on an optional dependency without
4142
# requiring the dependency. Rather than introduce additional complexity, we

libgit2-sys/build.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ use std::process::Command;
77
fn main() {
88
let https = env::var("CARGO_FEATURE_HTTPS").is_ok();
99
let ssh = env::var("CARGO_FEATURE_SSH").is_ok();
10+
let vendored = env::var("CARGO_FEATURE_VENDORED").is_ok();
1011
let zlib_ng_compat = env::var("CARGO_FEATURE_ZLIB_NG_COMPAT").is_ok();
1112

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

0 commit comments

Comments
 (0)