extern crate bindgen;
use std::env;
use std::path::PathBuf;
use std::process::Command;
const H_FILE_NAME: &str = "/libpros.h";
const CC: &str = "gcc";
pub fn bindgen(){
println!("cargo:rerun-if-changed=include");
println!("Generating PROS bindings");
let out_dir =env::var("OUT_DIR").unwrap();
let out_h_loc = out_dir + H_FILE_NAME;
Command::new(CC)
.arg("-I").arg("./include/")
.arg("-E").arg("include/rust.h")
.arg("-o").arg(out_h_loc.clone())
.output()
.expect("failed to preprocess code");
let bindings = bindgen::Builder::default()
.header(out_h_loc.clone())
.ctypes_prefix("::libc")
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
println!("Generated PROS bindings")
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}