extern crate bindgen; use std::env; use std::path::Path; use std::process::Command; use bindgen::Builder; fn main() { let base = env::var("CARGO_MANIFEST_DIR").unwrap(); let out = env::var("OUT_DIR").unwrap(); build(Path::new(&base), Path::new(&out)); } fn build(base: &Path, out: &Path) { let bearssl = base.join("BearSSL"); let header = bearssl.join("inc").join("bearssl.h"); let build = bearssl.join("build"); Command::new("make").current_dir(&bearssl).status().unwrap(); println!("cargo:rustc-link-search=native={}", build.display()); println!("cargo:rustc-link-lib=static=bearssl"); let gen = Builder::default().header(header.to_string_lossy()); gen.generate().unwrap().write_to_file(out.join("bearssl.rs")).unwrap(); }