Programmatically locate the system SDK path for bindgen
This commit is contained in:
committed by
Antonio Scandurra
parent
4440c9b18e
commit
99cb66dfb0
+12
-2
@@ -1,4 +1,4 @@
|
||||
use std::{env, path::PathBuf};
|
||||
use std::{env, path::PathBuf, process::Command};
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rustc-link-lib=framework=CoreMedia");
|
||||
@@ -7,9 +7,19 @@ fn main() {
|
||||
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=12.3");
|
||||
println!("cargo:rustc-link-arg=-ObjC");
|
||||
|
||||
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();
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("src/bindings.h")
|
||||
.clang_arg("-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk")
|
||||
.clang_arg(format!("-isysroot{}", sdk_path))
|
||||
.allowlist_function("CMTimeMake")
|
||||
.allowlist_type("CMSampleBufferRef")
|
||||
.allowlist_var("_dispatch_main_q")
|
||||
|
||||
Reference in New Issue
Block a user