Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding of the libgit2 pkgconfig at build time #1065

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion libgit2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@ use std::process::Command;

/// Tries to use system libgit2 and emits necessary build script instructions.
fn try_system_libgit2() -> Result<pkg_config::Library, pkg_config::Error> {
// Specify `LIBGIT2_OVERRIDE_PKGCONFIG_NAME` to change the name of the pkgconfig configuration
// that will be looked for when checking to see if the system libgit2 is usable. This is
// most useful for distributions that may ship co-installable versions of libgit2 where
// the pkgconfig may be renamed.
println!("cargo:rerun-if-env-changed=LIBGIT2_OVERRIDE_PKGCONFIG_NAME");
let libgit2_pkgconfig =
env::var("LIBGIT2_OVERRIDE_PKGCONFIG_NAME").unwrap_or("libgit2".to_string());

let mut cfg = pkg_config::Config::new();
match cfg.range_version("1.8.1".."1.9.0").probe("libgit2") {
match cfg
.range_version("1.8.1".."1.9.0")
.probe(&libgit2_pkgconfig)
{
Ok(lib) => {
for include in &lib.include_paths {
println!("cargo:root={}", include.display());
Expand Down