Generate simpleservo.h in appropriate target directory.

This commit is contained in:
Josh Matthews 2019-07-22 22:16:22 -04:00 committed by GitHub
parent 28f7a87186
commit 6fa8e30e1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,17 +3,25 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::env;
use std::path::PathBuf;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let target_dir = env::var("CARGO_TARGET_DIR").unwrap();
let mut path: PathBuf = [crate_dir.clone(), target_dir].iter().collect();
let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
if target != host {
path.push(target);
}
let profile_dir = env::var("PROFILE").unwrap();
let dest = format!("{}/{}/{}", target_dir, profile_dir, "simpleservo.h");
path.push(profile_dir);
path.push("simpleservo.h");
cbindgen::Builder::new()
.with_crate(crate_dir)
.with_language(cbindgen::Language::C)
.exclude_item("OutputDebugStringA")
.generate()
.expect("Unable to generate bindings")
.write_to_file(dest);
.write_to_file(path);
}