Skip to content

Commit

Permalink
Merge pull request #51 from madsmtm/fix-audiounit-linking
Browse files Browse the repository at this point in the history
Fix AudioUnit linking
  • Loading branch information
simlay authored Jan 27, 2022
2 parents 6602318 + ef76b05 commit f7f7b02
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/coreaudio-sys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ jobs:
# Run cargo test with default, no and all features.
macos-test:
runs-on: macOS-latest
strategy:
matrix:
toolchain: [stable, nightly]
steps:
- uses: actions/checkout@v2
- name: Install llvm and clang
Expand All @@ -12,7 +15,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: ${{ matrix.toolchain }}
override: true
- name: cargo test
run: cargo test --verbose
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "coreaudio-sys"
version = "0.2.8"
version = "0.2.9"
authors = ["Mitchell Nordine <[email protected]>"]
description = "Bindings for Apple's CoreAudio frameworks generated via rust-bindgen"
license = "MIT"
Expand Down
26 changes: 21 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,32 @@ fn build(sdk_path: Option<&str>, target: &str) {

let mut headers: Vec<&'static str> = vec![];

#[cfg(feature = "audio_toolbox")]
#[cfg(feature = "audio_unit")]
{
println!("cargo:rustc-link-lib=framework=AudioToolbox");
headers.push("AudioToolbox/AudioToolbox.h");
// Since iOS 10.0 and macOS 10.12, all the functionality in AudioUnit
// moved to AudioToolbox, and the AudioUnit headers have been simple
// wrappers ever since.
if target.contains("apple-ios") {
// On iOS, the AudioUnit framework does not have (and never had) an
// actual dylib to link to, it is just a few header files.
// The AudioToolbox framework contains the symbols instead.
println!("cargo:rustc-link-lib=framework=AudioToolbox");
} else {
// On macOS, the symbols are present in the AudioToolbox framework,
// but only on macOS 10.12 and above.
//
// However, unlike on iOS, the AudioUnit framework on macOS
// contains a dylib with the desired symbols, that we can link to
// (in later versions just re-exports from AudioToolbox).
println!("cargo:rustc-link-lib=framework=AudioUnit");
}
headers.push("AudioUnit/AudioUnit.h");
}

#[cfg(feature = "audio_unit")]
#[cfg(feature = "audio_toolbox")]
{
println!("cargo:rustc-link-lib=framework=AudioToolbox");
headers.push("AudioUnit/AudioUnit.h");
headers.push("AudioToolbox/AudioToolbox.h");
}

#[cfg(feature = "core_audio")]
Expand Down

0 comments on commit f7f7b02

Please sign in to comment.