From 9d65b3b4ace313f0f24d7da576e2aec21171510e Mon Sep 17 00:00:00 2001 From: Michael Hills Date: Sun, 30 Jan 2022 00:50:17 +1100 Subject: [PATCH] WIP objc/block support --- Cargo.toml | 6 +++++- build.rs | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ff99924..5aa0add 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,14 @@ repository = "https://github.com/RustAudio/coreaudio-sys.git" build = "build.rs" [build-dependencies.bindgen] -version = "0.56" +version = "0.59.2" default-features = false features = ["runtime"] +[dependencies] +objc = { version = "0.2.7", optional = true } +block = { version = "0.1.6", optional = true } + [features] default = ["audio_toolbox", "audio_unit", "core_audio", "open_al", "core_midi"] audio_toolbox = [] diff --git a/build.rs b/build.rs index dd83151..e967a1f 100644 --- a/build.rs +++ b/build.rs @@ -125,11 +125,24 @@ fn build(sdk_path: Option<&str>, target: &str) { if let Some(sdk_path) = sdk_path { builder = builder.clang_args(&["-isysroot", sdk_path]); } - if target.contains("apple-ios") { + #[cfg(feature = "objc")] + { // time.h as has a variable called timezone that conflicts with some of the objective-c // calls from NSCalendar.h in the Foundation framework. This removes that one variable. - builder = builder.blacklist_item("timezone"); - builder = builder.blacklist_item("objc_object"); + builder = builder.blocklist_item("timezone"); + // fails to derive Copy + builder = builder.blocklist_item("objc_object"); + // fails to derive Copy + builder = builder.blocklist_item("AudioUnitRenderContext"); + + builder = builder.clang_args(&["-x", "objective-c"]); + builder = builder.objc_extern_crate(true); + } + #[cfg(feature = "block")] + { + builder = builder.clang_args(&["-fblocks"]); + builder = builder.generate_block(true); + builder = builder.block_extern_crate(true); } let meta_header: Vec<_> = headers