| 1 | use std::env; |
| 2 | use std::path::PathBuf; |
| 3 | |
| 4 | pub fn main() -> std::io::Result<()> { |
| 5 | let ac = autocfg::new(); |
| 6 | ac.emit_has_path("std::ffi::c_char"); |
| 7 | |
| 8 | let crate_root = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); |
| 9 | let git_root = crate_root.join("../.."); |
| 10 | let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); |
| 11 | |
| 12 | let make_output = make_cmd::gnu_make() |
| 13 | .env("DEVELOPER", "1") |
| 14 | .env_remove("PROFILE") |
| 15 | .current_dir(git_root.clone()) |
| 16 | .args([ |
| 17 | "INCLUDE_LIBGIT_RS=YesPlease", |
| 18 | "contrib/libgit-sys/libgitpub.a", |
| 19 | ]) |
| 20 | .output() |
| 21 | .expect("Make failed to run"); |
| 22 | if !make_output.status.success() { |
| 23 | panic!( |
| 24 | "Make failed:\n stdout = {}\n stderr = {}\n", |
| 25 | String::from_utf8(make_output.stdout).unwrap(), |
| 26 | String::from_utf8(make_output.stderr).unwrap() |
| 27 | ); |
| 28 | } |
| 29 | std::fs::copy(crate_root.join("libgitpub.a"), dst.join("libgitpub.a"))?; |
| 30 | println!("cargo:rustc-link-search=native={}", dst.display()); |
| 31 | println!("cargo:rustc-link-lib=gitpub"); |
| 32 | println!("cargo:rerun-if-changed={}", git_root.display()); |
| 33 | |
| 34 | Ok(()) |
| 35 | } |