2022-08-29 22:25:37 +00:00
|
|
|
use std::{env, path::PathBuf, process::Command};
|
2022-08-29 22:07:33 +00:00
|
|
|
|
2022-08-26 21:10:26 +00:00
|
|
|
fn main() {
|
2022-08-29 16:00:51 +00:00
|
|
|
println!("cargo:rustc-link-lib=framework=CoreMedia");
|
2022-08-29 22:07:33 +00:00
|
|
|
println!("cargo:rustc-link-lib=framework=ScreenCaptureKit");
|
|
|
|
println!("cargo:rustc-link-lib=framework=System");
|
2022-08-29 16:00:51 +00:00
|
|
|
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=12.3");
|
2022-08-29 17:15:49 +00:00
|
|
|
println!("cargo:rustc-link-arg=-ObjC");
|
2022-08-29 16:00:51 +00:00
|
|
|
|
2022-08-29 22:25:37 +00:00
|
|
|
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();
|
|
|
|
|
2022-08-29 22:07:33 +00:00
|
|
|
let bindings = bindgen::Builder::default()
|
|
|
|
.header("src/bindings.h")
|
2022-08-29 22:25:37 +00:00
|
|
|
.clang_arg(format!("-isysroot{}", sdk_path))
|
2022-08-29 22:07:33 +00:00
|
|
|
.allowlist_function("CMTimeMake")
|
|
|
|
.allowlist_type("CMSampleBufferRef")
|
|
|
|
.allowlist_var("_dispatch_main_q")
|
|
|
|
.allowlist_function("dispatch_async_f")
|
|
|
|
.allowlist_function("dispatch_queue_create")
|
|
|
|
.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");
|
|
|
|
|
2022-08-29 16:00:51 +00:00
|
|
|
cc::Build::new()
|
|
|
|
.file("src/dummy.m")
|
2022-08-29 17:59:58 +00:00
|
|
|
.flag("-mmacosx-version-min=12.3")
|
2022-08-29 16:00:51 +00:00
|
|
|
.compile("dummy");
|
2022-08-26 21:10:26 +00:00
|
|
|
}
|