Files
2022-03-07 12:55:28 -04:00

38 lines
1.0 KiB
Rust

extern crate cbindgen;
use cbindgen::{Config, Language};
use std::env;
use std::path::PathBuf;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let package_name = env::var("CARGO_PKG_NAME").unwrap();
let output_file = target_dir()
.join(format!("{}.h", package_name))
.display()
.to_string();
let config = Config {
// defines: HashMap::from([
// ("target_os = ios".into(), "TARGET_OS_IOS".into()),
// ("target_os = macos".into(), "TARGET_OS_MACOS".into()),
// ("target_os = android".into(), "TARGET_OS_ANDROID".into()),
// ]),
language: Language::C,
..Default::default()
};
cbindgen::generate_with_config(&crate_dir, config)
.unwrap()
.write_to_file(&output_file);
}
fn target_dir() -> PathBuf {
if let Ok(target) = env::var("CARGO_TARGET_DIR") {
PathBuf::from(target)
} else {
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("target")
}
}