2024-01-30 05:04:15 +03:00
|
|
|
#[cfg(target_os = "macos")]
|
2022-08-31 12:02:48 +03:00
|
|
|
fn main() {
|
2024-01-30 05:04:15 +03:00
|
|
|
use std::{env, path::PathBuf, process::Command};
|
|
|
|
|
2022-08-31 12:02:48 +03:00
|
|
|
let sdk_path = String::from_utf8(
|
|
|
|
Command::new("xcrun")
|
2023-01-02 07:50:45 +03:00
|
|
|
.args(["--sdk", "macosx", "--show-sdk-path"])
|
2022-08-31 12:02:48 +03:00
|
|
|
.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")
|
2022-08-31 16:49:55 +03:00
|
|
|
.allowlist_type("CMItemIndex")
|
|
|
|
.allowlist_type("CMSampleTimingInfo")
|
|
|
|
.allowlist_type("CMVideoCodecType")
|
|
|
|
.allowlist_type("VTEncodeInfoFlags")
|
2022-08-31 15:33:58 +03:00
|
|
|
.allowlist_function("CMTimeMake")
|
2022-08-31 12:02:48 +03:00
|
|
|
.allowlist_var("kCVPixelFormatType_.*")
|
2022-08-31 12:09:14 +03:00
|
|
|
.allowlist_var("kCVReturn.*")
|
2022-08-31 16:49:55 +03:00
|
|
|
.allowlist_var("VTEncodeInfoFlags_.*")
|
|
|
|
.allowlist_var("kCMVideoCodecType_.*")
|
|
|
|
.allowlist_var("kCMTime.*")
|
2022-08-31 19:02:05 +03:00
|
|
|
.allowlist_var("kCMSampleAttachmentKey_.*")
|
2022-08-31 12:02:48 +03:00
|
|
|
.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");
|
|
|
|
}
|
2024-01-30 05:04:15 +03:00
|
|
|
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
|
|
fn main() {}
|