2026-03-16 00:38:57 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2026-03-16 14:23:52 +00:00
|
|
|
use std::{env, time};
|
2026-03-15 23:42:55 +00:00
|
|
|
|
|
|
|
|
fn main() {
|
2026-03-16 00:38:57 +00:00
|
|
|
let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
|
|
|
|
let target_dir = PathBuf::from(env::var("CARGO_BUILD_TARGET_DIR").unwrap());
|
|
|
|
|
|
|
|
|
|
run_cbindgen(&cargo_dir, &target_dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run_cbindgen(cargo_dir: &Path, target_dir: &Path) {
|
|
|
|
|
let out = target_dir.join("drone_controller.h");
|
|
|
|
|
|
|
|
|
|
cbindgen::Builder::new()
|
|
|
|
|
.with_crate(cargo_dir)
|
2026-03-16 01:00:31 +00:00
|
|
|
.with_language(cbindgen::Language::Cxx)
|
2026-03-16 00:38:57 +00:00
|
|
|
.generate()
|
|
|
|
|
.expect("Unable to generate bindings")
|
|
|
|
|
.write_to_file(&out);
|
2026-03-15 23:42:55 +00:00
|
|
|
|
2026-03-16 00:38:57 +00:00
|
|
|
println!("cargo:rerun-if-changed={}", out.display());
|
2026-03-16 14:23:52 +00:00
|
|
|
println!(
|
|
|
|
|
"cargo:rerun-if-changed={}",
|
|
|
|
|
time::SystemTime::now()
|
|
|
|
|
.duration_since(time::UNIX_EPOCH)
|
|
|
|
|
.unwrap()
|
|
|
|
|
.as_secs()
|
|
|
|
|
);
|
2026-03-15 23:42:55 +00:00
|
|
|
}
|