drone_controller/build.rs

34 lines
962 B
Rust
Raw Permalink Normal View History

2026-03-16 00:38:57 +00:00
use std::path::{Path, PathBuf};
use std::{env, time};
2026-03-15 23:42:55 +00:00
fn main() {
if env::var("CARGO_BUILD_TARGET_DIR").is_ok() {
let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let target_dir = PathBuf::from(env::var("CARGO_BUILD_TARGET_DIR").unwrap());
2026-03-16 00:38:57 +00:00
run_cbindgen(&cargo_dir, &target_dir);
}
2026-03-16 00:38:57 +00:00
}
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)
.with_namespace("dcont")
2026-03-26 23:16:31 +00:00
.with_pragma_once(true)
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());
println!(
"cargo:rerun-if-changed={}",
time::SystemTime::now()
.duration_since(time::UNIX_EPOCH)
.unwrap()
.as_secs()
);
2026-03-15 23:42:55 +00:00
}