2022-08-29 22:25:37 +00:00
|
|
|
use std::{env, path::PathBuf, process::Command};
|
2022-08-29 22:07:33 +00:00
|
|
|
|
2022-09-02 18:56:38 +00:00
|
|
|
fn main() {
|
|
|
|
println!(
|
|
|
|
"cargo:rustc-link-search=framework={}",
|
|
|
|
"crates/live_kit/LiveKitBridge/.build/arm64-apple-macosx/debug"
|
|
|
|
);
|
2022-09-02 09:42:39 +00:00
|
|
|
|
2022-09-02 18:56:38 +00:00
|
|
|
// Find frameworks as a sibling of the executable at runtime
|
|
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");
|
2022-09-02 09:42:39 +00:00
|
|
|
|
2022-08-29 22:07:33 +00:00
|
|
|
println!("cargo:rustc-link-lib=framework=ScreenCaptureKit");
|
2022-08-29 16:00:51 +00:00
|
|
|
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=12.3");
|
|
|
|
|
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-30 09:12:40 +00:00
|
|
|
println!("cargo:rerun-if-changed=src/bindings.h");
|
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-30 01:08:07 +00:00
|
|
|
.clang_arg("-xobjective-c")
|
2022-08-30 19:15:38 +00:00
|
|
|
.allowlist_function("dispatch_queue_create")
|
2022-08-30 01:08:07 +00:00
|
|
|
.allowlist_type("SCStreamOutputType")
|
2022-08-30 13:49:07 +00:00
|
|
|
.allowlist_type("SCFrameStatus")
|
|
|
|
.allowlist_var("SCStreamFrameInfo.*")
|
2022-08-29 22:07:33 +00: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");
|
2022-08-26 21:10:26 +00:00
|
|
|
}
|