mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
30 lines
970 B
Rust
30 lines
970 B
Rust
use std::{env, path::PathBuf, process::Command};
|
|
|
|
fn main() {
|
|
let sdk_path = String::from_utf8(
|
|
Command::new("xcrun")
|
|
.args(&["--sdk", "macosx", "--show-sdk-path"])
|
|
.output()
|
|
.unwrap()
|
|
.stdout,
|
|
)
|
|
.unwrap();
|
|
let sdk_path = sdk_path.trim_end();
|
|
|
|
println!("cargo:rerun-if-changed=src/bindings.h");
|
|
let bindings = bindgen::Builder::default()
|
|
.header("src/bindings.h")
|
|
.clang_arg(format!("-isysroot{}", sdk_path))
|
|
.clang_arg("-xobjective-c")
|
|
.allowlist_var("kCVPixelFormatType_.*")
|
|
.allowlist_var("kCVReturn.*")
|
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
|
.layout_tests(false)
|
|
.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 dispatch bindings");
|
|
}
|