Skip to content

Commit

Permalink
Allow overriding lib/include dirs when cross-compiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicah committed Apr 22, 2017
1 parent 06598dd commit 6f9bdf7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions libgit2-sys/build.rs
Expand Up @@ -29,6 +29,21 @@ fn main() {
if curl {
register_dep("CURL");
}

let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();

if target != host {
let lib_dir = env::var_os("TARGET_LIBGIT2_LIB_DIR").map(PathBuf::from);
let include_dir = env::var_os("TARGET_LIBGIT2_INCLUDE_DIR").map(PathBuf::from);

if lib_dir.is_some() && include_dir.is_some() {
println!("cargo:rustc-link-search=native={}", lib_dir.unwrap().to_string_lossy());
println!("cargo:include={}", include_dir.unwrap().to_string_lossy());
println!("cargo:rustc-link-lib=dylib=git2");
return;
}
}
let has_pkgconfig = Command::new("pkg-config").output().is_ok();

if env::var("LIBGIT2_SYS_USE_PKG_CONFIG").is_ok() {
Expand All @@ -42,8 +57,6 @@ fn main() {
.status();
}

let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
let windows = target.contains("windows");
let msvc = target.contains("msvc");
let mut cfg = cmake::Config::new("libgit2");
Expand Down

0 comments on commit 6f9bdf7

Please sign in to comment.