From 7a64d3244b6dee6003abf6ea9b1bd54150aee6a0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 27 Jan 2016 10:47:02 -0800 Subject: [PATCH] Detect when http_parser is being linked to Closes #97 --- libgit2-sys/build.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libgit2-sys/build.rs b/libgit2-sys/build.rs index b4321193ff..5bc137fb45 100644 --- a/libgit2-sys/build.rs +++ b/libgit2-sys/build.rs @@ -105,6 +105,23 @@ fn main() { return } + // libgit2 requires the http_parser library for the HTTP transport to be + // implemented, and it will attempt to use the system http_parser if it's + // available. Detect this situation and report using the system http parser + // the same way in this situation. + // + // Note that other dependencies of libgit2 like openssl, libz, and libssh2 + // are tracked via crates instead of this. Ideally this should be a crate as + // well. + let pkgconfig_file = dst.join("lib/pkgconfig/libgit2.pc"); + if let Ok(mut f) = File::open(&pkgconfig_file) { + let mut contents = String::new(); + t!(f.read_to_string(&mut contents)); + if contents.contains("-lhttp_parser") { + println!("cargo:rustc-link-lib=http_parser"); + } + } + println!("cargo:rustc-link-lib=static=git2"); println!("cargo:rustc-link-search=native={}", dst.join("lib").display()); if target.contains("apple") {