From b9847d2a842482443affcce380498956a5d799d6 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 09:21:39 -0400 Subject: [PATCH 01/60] feat(apple): added visionOS support --- .github/workflows/coreaudio-sys.yml | 27 ++++++++++++++++++++++ Cargo.toml | 6 ++--- README.md | 2 +- build.rs | 35 +++++++++++++++++++---------- src/lib.rs | 2 +- 5 files changed, 55 insertions(+), 17 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index f03b950..3e0fbf6 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -47,6 +47,33 @@ jobs: - name: Build for iOS target ${{matrix.target}} run: cargo build --verbose --target=${{matrix.target}} + visionos-check: + runs-on: macOS-14 + strategy: + matrix: + toolchain: [stable, nightly] + target: [aarch64-apple-visionos, aarch64-apple-visionos-sim] + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + with: + profile: minimal + toolchain: ${{ matrix.toolchain }} + targets: ${{ matrix.target }} + + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v2.0.3 + with: + # this is LLVM version that added support for visionOS + # https://github.com/llvm/llvm-project/pull/77707 + version: "18.1.0" + + - name: add visionos targets + run: rustup target add ${{matrix.target}} + + - name: Build for iOS target ${{matrix.target}} + run: cargo +nightly build -Zbuild-std,panic=abort --verbose --target=${{matrix.target}} + # Build the docs with all features to make sure docs.rs will work. macos-docs: runs-on: macOS-latest diff --git a/Cargo.toml b/Cargo.toml index 22eea86..d40c171 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.2.15" authors = ["Mitchell Nordine "] description = "Bindings for Apple's CoreAudio frameworks generated via rust-bindgen" license = "MIT" -keywords = ["core", "audio", "unit", "osx", "ios"] +keywords = ["core", "audio", "unit", "osx", "ios", "visionos"] readme = "README.md" homepage = "https://github.com/RustAudio/coreaudio-sys" repository = "https://github.com/RustAudio/coreaudio-sys.git" @@ -27,5 +27,5 @@ core_midi = [] [package.metadata.docs.rs] all-features = true -default-target = "x86_64-apple-darwin" -targets = ["x86_64-apple-darwin", "x86_64-apple-ios"] +default-target = "aarch64-apple-darwin" +targets = ["x86_64-apple-darwin", "x86_64-apple-ios", "aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-visionos"] diff --git a/README.md b/README.md index e6cacf3..b5fbf29 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # coreaudio-sys [![Actions Status](https://github.com/rustaudio/coreaudio-sys/workflows/coreaudio-sys/badge.svg)](https://github.com/rustaudio/coreaudio-sys/actions) [![Crates.io](https://img.shields.io/crates/v/coreaudio-sys.svg)](https://crates.io/crates/coreaudio-sys) [![Crates.io](https://img.shields.io/crates/l/coreaudio-sys.svg)](https://github.com/RustAudio/coreaudio-sys/blob/master/LICENSE) [![docs.rs](https://docs.rs/coreaudio-sys/badge.svg)](https://docs.rs/coreaudio-sys/) -Raw bindings to Apple's Core Audio API for macos and iOS generated using [rust-bindgen](https://github.com/rust-lang-nursery/rust-bindgen). [coreaudio-rs](https://github.com/RustAudio/coreaudio-rs) is an attempt at offering a higher level API around this crate. +Raw bindings to Apple's Core Audio API for macos and iOS and visionOS generated using [rust-bindgen](https://github.com/rust-lang-nursery/rust-bindgen). [coreaudio-rs](https://github.com/RustAudio/coreaudio-rs) is an attempt at offering a higher level API around this crate. ## Cross Compiling diff --git a/build.rs b/build.rs index f3373cd..6bf38a9 100644 --- a/build.rs +++ b/build.rs @@ -21,6 +21,10 @@ fn sdk_path(target: &str) -> Result { || target == "armv7s-apple-ios" { "iphoneos" + } else if target == "aarch64-apple-visionos" { + "xros" + } else if target == "aarch64-apple-visionos-sim" { + "xrsimulator" } else { unreachable!(); }; @@ -45,11 +49,12 @@ fn build(sdk_path: Option<&str>, target: &str) { use std::env; use std::path::PathBuf; + #[allow(unused)] let mut headers: Vec<&'static str> = vec![]; #[cfg(feature = "audio_unit")] { - // Since iOS 10.0 and macOS 10.12, all the functionality in AudioUnit + // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. if target.contains("apple-ios") { @@ -61,7 +66,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // 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 + // However, unlike on iOS or visionOS, 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"); @@ -71,15 +76,17 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "audio_toolbox")] { - println!("cargo:rustc-link-lib=framework=AudioToolbox"); - headers.push("AudioToolbox/AudioToolbox.h"); + if !target.contains("apple-visionos") { + println!("cargo:rustc-link-lib=framework=AudioToolbox"); + headers.push("AudioToolbox/AudioToolbox.h"); + } } #[cfg(feature = "core_audio")] { println!("cargo:rustc-link-lib=framework=CoreAudio"); - if target.contains("apple-ios") { + if target.contains("apple-ios") || target.contains("apple-visionos") { headers.push("CoreAudio/CoreAudioTypes.h"); } else { headers.push("CoreAudio/CoreAudio.h"); @@ -100,14 +107,16 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "open_al")] { - println!("cargo:rustc-link-lib=framework=OpenAL"); - headers.push("OpenAL/al.h"); - headers.push("OpenAL/alc.h"); + if !target.contains("visionos") { + println!("cargo:rustc-link-lib=framework=OpenAL"); + headers.push("OpenAL/al.h"); + headers.push("OpenAL/alc.h"); + } } #[cfg(all(feature = "core_midi"))] { - if target.contains("apple-darwin") { + if target.contains("apple-darwin") && !target.contains("visionos") { println!("cargo:rustc-link-lib=framework=CoreMIDI"); headers.push("CoreMIDI/CoreMIDI.h"); } @@ -125,6 +134,8 @@ fn build(sdk_path: Option<&str>, target: &str) { // -arch arm64 but it looks cleaner to just change the target. let target = if target == "aarch64-apple-ios" { "arm64-apple-ios" + } else if target == "aarch64-apple-visionos" { + "arm64-apple-visionos" } else if target == "aarch64-apple-darwin" { "arm64-apple-darwin" } else { @@ -137,7 +148,7 @@ 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") { + if target.contains("apple-ios") || target.contains("apple-visionos") { // 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.blocklist_item("timezone"); @@ -169,8 +180,8 @@ fn build(sdk_path: Option<&str>, target: &str) { fn main() { let target = std::env::var("TARGET").unwrap(); - if !(target.contains("apple-darwin") || target.contains("apple-ios")) { - panic!("coreaudio-sys requires macos or ios target"); + if !(target.contains("apple-darwin") || target.contains("apple-ios") || target.contains("apple-visionos")) { + panic!("coreaudio-sys requires macos or ios or visionos target"); } let directory = sdk_path(&target).ok(); diff --git a/src/lib.rs b/src/lib.rs index c85c8e8..de3cf5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg(any(target_os = "macos", target_os = "ios"))] +#![cfg(any(target_os = "macos", target_os = "ios", target_os = "visionos"))] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] From c267ed40babb33a0c3ecc7e6215dacbff4ba52bc Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 09:42:58 -0400 Subject: [PATCH 02/60] fixed typo in github action --- .github/workflows/coreaudio-sys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 3e0fbf6..e91a14f 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -71,7 +71,7 @@ jobs: - name: add visionos targets run: rustup target add ${{matrix.target}} - - name: Build for iOS target ${{matrix.target}} + - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Zbuild-std,panic=abort --verbose --target=${{matrix.target}} # Build the docs with all features to make sure docs.rs will work. From 873bb319026270219bd2a45fa495ab5a69a12668 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 09:59:52 -0400 Subject: [PATCH 03/60] replaced rust-toolchain with simple command line call in CI --- .github/workflows/coreaudio-sys.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index e91a14f..4a005f8 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -55,11 +55,9 @@ jobs: target: [aarch64-apple-visionos, aarch64-apple-visionos-sim] steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly with: - profile: minimal - toolchain: ${{ matrix.toolchain }} - targets: ${{ matrix.target }} + run: + rustup install nightly --profile minimal - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 From 23d3167b2e7a637ae96b637b2650be371cb7a00e Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 10:09:27 -0400 Subject: [PATCH 04/60] latest LLVM --- .github/workflows/coreaudio-sys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 4a005f8..f0a519d 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -64,7 +64,7 @@ jobs: with: # this is LLVM version that added support for visionOS # https://github.com/llvm/llvm-project/pull/77707 - version: "18.1.0" + version: "18.1.6" - name: add visionos targets run: rustup target add ${{matrix.target}} From 61e5ad5b4c724d7bcf97d6e46cf8848863519453 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 11:17:01 -0400 Subject: [PATCH 05/60] trying LLVM 17.0.6 --- .github/workflows/coreaudio-sys.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index f0a519d..78e4319 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -64,7 +64,8 @@ jobs: with: # this is LLVM version that added support for visionOS # https://github.com/llvm/llvm-project/pull/77707 - version: "18.1.6" + # version: "18.1.0" + version: "17.0.6" - name: add visionos targets run: rustup target add ${{matrix.target}} From cfff85868a187b221836ca29bdb49204b2d0db60 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 14:07:01 -0400 Subject: [PATCH 06/60] Update coreaudio-sys.yml --- .github/workflows/coreaudio-sys.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 78e4319..23b4b78 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -67,8 +67,8 @@ jobs: # version: "18.1.0" version: "17.0.6" - - name: add visionos targets - run: rustup target add ${{matrix.target}} + # - name: add visionos targets + # run: rustup target add ${{matrix.target}} - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Zbuild-std,panic=abort --verbose --target=${{matrix.target}} From 69f824aaae78d9c5bcd33cb979db09785216fc70 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 14:15:47 -0400 Subject: [PATCH 07/60] Update coreaudio-sys.yml --- .github/workflows/coreaudio-sys.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 23b4b78..fa7a1c9 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -56,8 +56,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - run: - rustup install nightly --profile minimal + run: rustup install nightly --profile minimal - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 @@ -67,11 +66,11 @@ jobs: # version: "18.1.0" version: "17.0.6" - # - name: add visionos targets - # run: rustup target add ${{matrix.target}} + - name: add visionos targets + run: rustup target add ${{matrix.target}} - name: Build for visionOS target ${{matrix.target}} - run: cargo +nightly build -Zbuild-std,panic=abort --verbose --target=${{matrix.target}} + run: cargo +nightly build -Zbuild-std --verbose --target=${{matrix.target}} # Build the docs with all features to make sure docs.rs will work. macos-docs: From e06b1acbe051485cf1614c9f558e143ba0e934f8 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 14:21:34 -0400 Subject: [PATCH 08/60] Update coreaudio-sys.yml --- .github/workflows/coreaudio-sys.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index fa7a1c9..fad8b07 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -51,19 +51,19 @@ jobs: runs-on: macOS-14 strategy: matrix: - toolchain: [stable, nightly] target: [aarch64-apple-visionos, aarch64-apple-visionos-sim] steps: - uses: actions/checkout@v4 - with: - run: rustup install nightly --profile minimal + + - name: Install rust nightly + run: rustup install nightly --profile minimal - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 with: # this is LLVM version that added support for visionOS # https://github.com/llvm/llvm-project/pull/77707 - # version: "18.1.0" + # version: "18.1.0" # no apple build yet version: "17.0.6" - name: add visionos targets From 7b7d54267fb3d32c82d8bf06055632ac3bbeb29d Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 14:27:56 -0400 Subject: [PATCH 09/60] Update coreaudio-sys.yml --- .github/workflows/coreaudio-sys.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index fad8b07..8e0821f 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -55,8 +55,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install rust nightly - run: rustup install nightly --profile minimal + # - name: Install rust nightly + # run: rustup install nightly --profile minimal + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 From 18719e468dfcff6e0cb7ddb103856211a88d3b4d Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 14:35:50 -0400 Subject: [PATCH 10/60] Update coreaudio-sys.yml --- .github/workflows/coreaudio-sys.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 8e0821f..355f461 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -69,11 +69,11 @@ jobs: # version: "18.1.0" # no apple build yet version: "17.0.6" - - name: add visionos targets - run: rustup target add ${{matrix.target}} + # - name: add visionos targets + # run: rustup target add ${{matrix.target}} - name: Build for visionOS target ${{matrix.target}} - run: cargo +nightly build -Zbuild-std --verbose --target=${{matrix.target}} + run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} # Build the docs with all features to make sure docs.rs will work. macos-docs: From 53545c8631239af96cdafd66ddb81f3f410c3655 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 14:45:13 -0400 Subject: [PATCH 11/60] Update coreaudio-sys.yml --- .github/workflows/coreaudio-sys.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 355f461..8bfed9b 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -59,6 +59,7 @@ jobs: # run: rustup install nightly --profile minimal - uses: dtolnay/rust-toolchain@master with: + profile: minimal toolchain: nightly - name: Install LLVM and Clang From 345680d6e0748b18961463557947bf036a4db380 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 14:56:41 -0400 Subject: [PATCH 12/60] Update coreaudio-sys.yml added rust-src --- .github/workflows/coreaudio-sys.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 8bfed9b..57860f2 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -35,6 +35,8 @@ jobs: with: toolchain: ${{ matrix.toolchain }} targets: ${{ matrix.target }} + components: rust-src + # rustup component add rust-src --toolchain nightly-aarch64-apple-darwin - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 From fadd3e1932ce0b8dfe42989ca98c721aa279814d Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 15:05:08 -0400 Subject: [PATCH 13/60] added rust-src to visionos --- .github/workflows/coreaudio-sys.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 57860f2..114f4b8 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -34,9 +34,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} - targets: ${{ matrix.target }} - components: rust-src - # rustup component add rust-src --toolchain nightly-aarch64-apple-darwin + targets: ${{ matrix.target }} - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 @@ -63,6 +61,8 @@ jobs: with: profile: minimal toolchain: nightly + components: rust-src + # rustup component add rust-src --toolchain nightly-aarch64-apple-darwin - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 From 7cdd572b9fbf3182b07ab069dfb1c4d2e6431230 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 15:14:09 -0400 Subject: [PATCH 14/60] updated build.rs --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 6bf38a9..8ddcb52 100644 --- a/build.rs +++ b/build.rs @@ -57,7 +57,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios") { + if target.contains("apple-ios") || target.contains("apple-visionos") { // 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. From afd9d6985b4ef3bd2a606529a3c61782e4827ee0 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 15:28:14 -0400 Subject: [PATCH 15/60] macOS-latest --- .github/workflows/coreaudio-sys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 114f4b8..9f2bed3 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -48,7 +48,7 @@ jobs: run: cargo build --verbose --target=${{matrix.target}} visionos-check: - runs-on: macOS-14 + runs-on: macOS-latest strategy: matrix: target: [aarch64-apple-visionos, aarch64-apple-visionos-sim] From cf2ef1d29ddd958b5b653c23aed548f6865d5e9e Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 15:47:57 -0400 Subject: [PATCH 16/60] added Xcode Command Line Tools --- .github/workflows/coreaudio-sys.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 9f2bed3..ded4858 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -71,6 +71,9 @@ jobs: # https://github.com/llvm/llvm-project/pull/77707 # version: "18.1.0" # no apple build yet version: "17.0.6" + + - name: Install Xcode Command Line Tools + run: xcode-select --install # - name: add visionos targets # run: rustup target add ${{matrix.target}} From 4630bb51025ab21ef8e7dc073546946c583a4525 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 16:00:06 -0400 Subject: [PATCH 17/60] there's already LLVM for visionos --- .github/workflows/coreaudio-sys.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index ded4858..4208724 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -64,16 +64,17 @@ jobs: components: rust-src # rustup component add rust-src --toolchain nightly-aarch64-apple-darwin - - name: Install LLVM and Clang - uses: KyleMayes/install-llvm-action@v2.0.3 - with: - # this is LLVM version that added support for visionOS - # https://github.com/llvm/llvm-project/pull/77707 - # version: "18.1.0" # no apple build yet - version: "17.0.6" + # seems like it's already installed + # - name: Install LLVM and Clang + # uses: KyleMayes/install-llvm-action@v2.0.3 + # with: + # # this is LLVM version that added support for visionOS + # # https://github.com/llvm/llvm-project/pull/77707 + # # version: "18.1.0" # no apple build yet + # version: "17.0.6" - - name: Install Xcode Command Line Tools - run: xcode-select --install + # - name: Install Xcode Command Line Tools + # run: xcode-select --install # - name: add visionos targets # run: rustup target add ${{matrix.target}} From a85974fe484710abaf317ccd821deb5eeed311e2 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 16:05:03 -0400 Subject: [PATCH 18/60] sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer --- .github/workflows/coreaudio-sys.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 4208724..64e0e90 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -73,8 +73,9 @@ jobs: # # version: "18.1.0" # no apple build yet # version: "17.0.6" - # - name: Install Xcode Command Line Tools - # run: xcode-select --install + - name: Install Xcode Command Line Tools + run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + # run: xcode-select --install # - name: add visionos targets # run: rustup target add ${{matrix.target}} From c8c3e7eeede2c68e07520af7067e2f87eaf7142b Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 16:14:15 -0400 Subject: [PATCH 19/60] list SDKs --- .github/workflows/coreaudio-sys.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 64e0e90..453d2d7 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -55,30 +55,17 @@ jobs: steps: - uses: actions/checkout@v4 - # - name: Install rust nightly - # run: rustup install nightly --profile minimal - uses: dtolnay/rust-toolchain@master with: profile: minimal toolchain: nightly components: rust-src - # rustup component add rust-src --toolchain nightly-aarch64-apple-darwin - # seems like it's already installed - # - name: Install LLVM and Clang - # uses: KyleMayes/install-llvm-action@v2.0.3 - # with: - # # this is LLVM version that added support for visionOS - # # https://github.com/llvm/llvm-project/pull/77707 - # # version: "18.1.0" # no apple build yet - # version: "17.0.6" - - name: Install Xcode Command Line Tools run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer - # run: xcode-select --install - # - name: add visionos targets - # run: rustup target add ${{matrix.target}} + - name: list SDKs + run: ls -lah /Library/Developer/CommandLineTools/SDKs/ - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} From 6d406240afa64364d968ac429710b94a28b95685 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 16:21:19 -0400 Subject: [PATCH 20/60] COREAUDIO_SDK_PATH --- .github/workflows/coreaudio-sys.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 453d2d7..fb03dbf 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -64,8 +64,8 @@ jobs: - name: Install Xcode Command Line Tools run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer - - name: list SDKs - run: ls -lah /Library/Developer/CommandLineTools/SDKs/ + - name: set COREAUDIO_SDK_PATH + run: export COREAUDIO_SDK_PATH=$(xcrun --sdk macosx --show-sdk-path) - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} From f64298e26d1517b53acdd4e73663afcaea4fffa5 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 16:29:43 -0400 Subject: [PATCH 21/60] print COREAUDIO_SDK_PATH in build.rs --- .github/workflows/coreaudio-sys.yml | 8 ++++---- build.rs | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index fb03dbf..62a0cdf 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -61,11 +61,11 @@ jobs: toolchain: nightly components: rust-src - - name: Install Xcode Command Line Tools - run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + # - name: Install Xcode Command Line Tools + # run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer - - name: set COREAUDIO_SDK_PATH - run: export COREAUDIO_SDK_PATH=$(xcrun --sdk macosx --show-sdk-path) + # - name: set COREAUDIO_SDK_PATH + # run: export COREAUDIO_SDK_PATH=$(xcrun --sdk macosx --show-sdk-path) - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} diff --git a/build.rs b/build.rs index 8ddcb52..5d9dba9 100644 --- a/build.rs +++ b/build.rs @@ -33,6 +33,9 @@ fn sdk_path(target: &str) -> Result { .output()? .stdout; let prefix_str = std::str::from_utf8(&output).expect("invalid output from `xcrun`"); + + println!("COREAUDIO_SDK_PATH - {prefix_str}"); + Ok(prefix_str.trim_end().to_string()) } From 9505f1717434c0fbe5e6947d648465f6d6f252b2 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 16:55:34 -0400 Subject: [PATCH 22/60] xcodebuild -showsdks --- .github/workflows/coreaudio-sys.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 62a0cdf..531a666 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -61,11 +61,11 @@ jobs: toolchain: nightly components: rust-src - # - name: Install Xcode Command Line Tools - # run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer - - # - name: set COREAUDIO_SDK_PATH - # run: export COREAUDIO_SDK_PATH=$(xcrun --sdk macosx --show-sdk-path) + - name: Install Xcode Command Line Tools + run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + + - name: Show Xcode SDKs + run: xcodebuild -showsdks - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} From 242bcfed7d7bb680502f8174cf78ac34b08c2bc9 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 17:02:06 -0400 Subject: [PATCH 23/60] moved to Xcode_15.4 --- .github/workflows/coreaudio-sys.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 531a666..50685d9 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -62,8 +62,10 @@ jobs: components: rust-src - name: Install Xcode Command Line Tools - run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer + # run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md - name: Show Xcode SDKs run: xcodebuild -showsdks From 14068bbd8b933099ae6808f903f987daf9d1e460 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 17:22:30 -0400 Subject: [PATCH 24/60] hack --- build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 5d9dba9..a63a6c6 100644 --- a/build.rs +++ b/build.rs @@ -22,9 +22,11 @@ fn sdk_path(target: &str) -> Result { { "iphoneos" } else if target == "aarch64-apple-visionos" { - "xros" + // "xros" + "iphoneos" //xros doesn't have the AudioUnit header, but ios does } else if target == "aarch64-apple-visionos-sim" { - "xrsimulator" + // "xrsimulator" + "iphonesimulator" //xros doesn't have the AudioUnit header, but ios does } else { unreachable!(); }; From 0155fdce89e625ead229ce2b6613eb7a4e40be87 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 19:41:21 -0400 Subject: [PATCH 25/60] conditional coreaudio.h --- build.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/build.rs b/build.rs index a63a6c6..0ac1c19 100644 --- a/build.rs +++ b/build.rs @@ -22,11 +22,9 @@ fn sdk_path(target: &str) -> Result { { "iphoneos" } else if target == "aarch64-apple-visionos" { - // "xros" - "iphoneos" //xros doesn't have the AudioUnit header, but ios does + "xros" } else if target == "aarch64-apple-visionos-sim" { - // "xrsimulator" - "iphonesimulator" //xros doesn't have the AudioUnit header, but ios does + "xrsimulator" } else { unreachable!(); }; @@ -81,10 +79,8 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "audio_toolbox")] { - if !target.contains("apple-visionos") { - println!("cargo:rustc-link-lib=framework=AudioToolbox"); - headers.push("AudioToolbox/AudioToolbox.h"); - } + println!("cargo:rustc-link-lib=framework=AudioToolbox"); + headers.push("AudioToolbox/AudioToolbox.h"); } #[cfg(feature = "core_audio")] @@ -170,7 +166,23 @@ fn build(sdk_path: Option<&str>, target: &str) { .map(|h| format!("#include <{}>\n", h)) .collect(); - builder = builder.header_contents("coreaudio.h", &meta_header.concat()); + + let fixes = if target.contains("apple-visionos") { + vec![ + // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:43:11: fatal error: 'AudioToolbox/AudioFileComponent.h' file not found + "#define TARGET_OS_IPHONE true\n", + // https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.13.sdk/usr/include/MacTypes.h#L289 + // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1633:8: error: unknown type name 'ItemCount' + "typedef unsigned long ItemCount;\n", + "typedef unsigned long ByteCount;\n" + ] + }else { + vec![""] + }; + + let contents = format!("{}{}", fixes.concat(), meta_header.concat()); + + builder = builder.header_contents("coreaudio.h", &contents); // Generate the bindings. builder = builder.trust_clang_mangling(false).derive_default(true); From 0689283c1e717839936fb7a8e27c47dc5f7f64ef Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 19:46:52 -0400 Subject: [PATCH 26/60] AudioUnit for visionos --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 0ac1c19..16c94b9 100644 --- a/build.rs +++ b/build.rs @@ -60,7 +60,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios") || target.contains("apple-visionos") { + 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. From 617079838f97893516832ec624dcd5ac66ad1c4c Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 19:52:34 -0400 Subject: [PATCH 27/60] search for AudioUnit.h in CI --- .github/workflows/coreaudio-sys.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 50685d9..f01ffc6 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -68,6 +68,9 @@ jobs: # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md - name: Show Xcode SDKs run: xcodebuild -showsdks + + - name: Find AudioUnit.h + run: find /Applications/Xcode.app -name AudioUnit.h - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} From 4eecbe5d27ad058b0c9f0ec7cdcd8b8b42751994 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 19:55:58 -0400 Subject: [PATCH 28/60] /Applications/Xcode_15.4.app --- .github/workflows/coreaudio-sys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index f01ffc6..84c2cff 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -70,7 +70,7 @@ jobs: run: xcodebuild -showsdks - name: Find AudioUnit.h - run: find /Applications/Xcode.app -name AudioUnit.h + run: find /Applications/Xcode_15.4.app -name AudioUnit.h - name: Build for visionOS target ${{matrix.target}} run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} From cc554fe7529723f4fe0122f66bf6218db885b604 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 5 Jun 2024 20:00:26 -0400 Subject: [PATCH 29/60] target.contains("apple-ios") --- build.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 16c94b9..10d5d5b 100644 --- a/build.rs +++ b/build.rs @@ -60,11 +60,12 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios") { + if target.contains("apple-ios") || target.contains("apple-visionos") { // 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"); + headers.push("AudioToolbox/AudioUnit.h"); } else { // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. @@ -73,8 +74,8 @@ fn build(sdk_path: Option<&str>, target: &str) { // 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"); } - headers.push("AudioUnit/AudioUnit.h"); } #[cfg(feature = "audio_toolbox")] From fc402e51a5be79ee341f0aae867432a7f62160a7 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 09:28:00 -0400 Subject: [PATCH 30/60] dump coreaudio.h --- build.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.rs b/build.rs index 10d5d5b..5d7fb21 100644 --- a/build.rs +++ b/build.rs @@ -183,6 +183,10 @@ fn build(sdk_path: Option<&str>, target: &str) { let contents = format!("{}{}", fixes.concat(), meta_header.concat()); + println!("============================="); + println!("{}",&contents); + println!("============================="); + builder = builder.header_contents("coreaudio.h", &contents); // Generate the bindings. From af251a9d44cfb03d197b90b93ce89195825d2031 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 10:49:38 -0400 Subject: [PATCH 31/60] AudioUnit/AudioUnit --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 5d7fb21..b7871b9 100644 --- a/build.rs +++ b/build.rs @@ -65,7 +65,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // 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"); - headers.push("AudioToolbox/AudioUnit.h"); + // headers.push("AudioToolbox/AudioUnit.h"); } else { // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. From 70d368db9ca1ebae2417d61cfae169a71a7087b8 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 11:09:23 -0400 Subject: [PATCH 32/60] added Kernel.framework --- build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.rs b/build.rs index b7871b9..04d40c5 100644 --- a/build.rs +++ b/build.rs @@ -146,6 +146,8 @@ fn build(sdk_path: Option<&str>, target: &str) { builder = builder.size_t_is_usize(true); builder = builder.clang_args(&[&format!("--target={}", target)]); + // idea from https://github.com/RustAudio/coreaudio-sys/issues/23#issuecomment-507364379 + builder = builder.clang_args(&["-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework", "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk//usr/include"]); if let Some(sdk_path) = sdk_path { builder = builder.clang_args(&["-isysroot", sdk_path]); From ed6723453be8189285b1087f62d7a3b37853be17 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 13:04:23 -0400 Subject: [PATCH 33/60] reverse --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 04d40c5..d5e2f99 100644 --- a/build.rs +++ b/build.rs @@ -65,7 +65,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // 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"); - // headers.push("AudioToolbox/AudioUnit.h"); + headers.push("AudioToolbox/AudioUnit.h"); } else { // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. @@ -147,7 +147,7 @@ fn build(sdk_path: Option<&str>, target: &str) { builder = builder.clang_args(&[&format!("--target={}", target)]); // idea from https://github.com/RustAudio/coreaudio-sys/issues/23#issuecomment-507364379 - builder = builder.clang_args(&["-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework", "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk//usr/include"]); + // builder = builder.clang_args(&["-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework", "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk//usr/include"]); if let Some(sdk_path) = sdk_path { builder = builder.clang_args(&["-isysroot", sdk_path]); From b129b3a11e03de2712ac49f23879b124cd833c40 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 13:12:36 -0400 Subject: [PATCH 34/60] bump --- build.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index d5e2f99..f248bb1 100644 --- a/build.rs +++ b/build.rs @@ -65,7 +65,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // 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"); - headers.push("AudioToolbox/AudioUnit.h"); + // headers.push("AudioToolbox/AudioUnit.h"); } else { // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. @@ -74,8 +74,9 @@ fn build(sdk_path: Option<&str>, target: &str) { // 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"); + // headers.push("AudioUnit/AudioUnit.h"); } + headers.push("AudioUnit/AudioUnit.h"); } #[cfg(feature = "audio_toolbox")] From 872175eec767a9306ad4cb5e28f754c3606d7ab9 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 13:55:31 -0400 Subject: [PATCH 35/60] bump --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index f248bb1..df489c5 100644 --- a/build.rs +++ b/build.rs @@ -60,7 +60,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios") || target.contains("apple-visionos") { + 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. From 50620318824931f89473760700aafb9e1e0d8214 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 14:09:23 -0400 Subject: [PATCH 36/60] fixed https://github.com/RustAudio/coreaudio-sys/pull/102#discussion_r1629881917 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index df489c5..6f41c76 100644 --- a/build.rs +++ b/build.rs @@ -110,7 +110,7 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "open_al")] { - if !target.contains("visionos") { + if target.contains("ios") { println!("cargo:rustc-link-lib=framework=OpenAL"); headers.push("OpenAL/al.h"); headers.push("OpenAL/alc.h"); From 282cebaab7a832f60fc5149aa96e438de2250854 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 14:09:58 -0400 Subject: [PATCH 37/60] https://github.com/RustAudio/coreaudio-sys/pull/102#discussion_r1629883634 --- .github/workflows/coreaudio-sys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 84c2cff..7e391ba 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -34,7 +34,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} - targets: ${{ matrix.target }} + targets: ${{ matrix.target }} - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 From 34434c4cfece88e73469b047dcc5ea3d17245e5d Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 14:27:58 -0400 Subject: [PATCH 38/60] bring CoreMIDI back to visionos --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 6f41c76..dc63156 100644 --- a/build.rs +++ b/build.rs @@ -119,7 +119,7 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(all(feature = "core_midi"))] { - if target.contains("apple-darwin") && !target.contains("visionos") { + if target.contains("apple-darwin") { println!("cargo:rustc-link-lib=framework=CoreMIDI"); headers.push("CoreMIDI/CoreMIDI.h"); } From dd3e2ddb479ebbf8d68cbf1fbf205035107fdd71 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:00:37 -0400 Subject: [PATCH 39/60] AudioToolbox/AudioUnit.h --- build.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index dc63156..6d63f5d 100644 --- a/build.rs +++ b/build.rs @@ -60,12 +60,12 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios"){ + if target.contains("apple-ios") || target.contains("apple-visionos"){ // 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"); - // headers.push("AudioToolbox/AudioUnit.h"); + headers.push("AudioToolbox/AudioUnit.h"); } else { // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. @@ -74,9 +74,9 @@ fn build(sdk_path: Option<&str>, target: &str) { // 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"); + headers.push("AudioUnit/AudioUnit.h"); } - headers.push("AudioUnit/AudioUnit.h"); + // headers.push("AudioUnit/AudioUnit.h"); } #[cfg(feature = "audio_toolbox")] From b54ac8b6ac6940f1baf913f4bf9ae1291011c470 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:04:34 -0400 Subject: [PATCH 40/60] added rust-toolchain.toml * according to https://github.com/RustAudio/coreaudio-sys/issues/78#issuecomment-1694986529 --- rust-toolchain.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..3fad4fd --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "nightly" +# channel = "stable" +components = ["rust-std", "rust-src", "rustc-dev", "llvm-tools-preview"] +targets = ["aarch64-apple-vision-sim"] \ No newline at end of file From c0ad6b6c0143afaa728573b1d75e2448c72c5a4a Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:07:47 -0400 Subject: [PATCH 41/60] added other targets to rust-toolchain.toml --- rust-toolchain.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 3fad4fd..2cf1049 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,6 @@ [toolchain] channel = "nightly" # channel = "stable" -components = ["rust-std", "rust-src", "rustc-dev", "llvm-tools-preview"] -targets = ["aarch64-apple-vision-sim"] \ No newline at end of file +# components = ["rust-std", "rust-src", "rustc-dev", "llvm-tools-preview"] +components = ["rust-src", "rustc-dev", "llvm-tools-preview"] +targets = ["aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", "aarch64-apple-vision", "aarch64-apple-vision-sim"] \ No newline at end of file From bd715a8e33af55723902f1343d408b091a5529e2 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:13:00 -0400 Subject: [PATCH 42/60] apple-tier-3-check * https://github.com/RustAudio/coreaudio-sys/pull/102#discussion_r1629885187 --- .github/workflows/coreaudio-sys.yml | 14 +++++++++----- rust-toolchain.toml | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 7e391ba..cecc903 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -6,7 +6,8 @@ jobs: runs-on: macOS-latest strategy: matrix: - toolchain: [stable, nightly] + # toolchain: [stable, nightly] + toolchain: [nightly] steps: - uses: actions/checkout@v4 - name: Install LLVM and Clang @@ -27,7 +28,8 @@ jobs: runs-on: macOS-14 strategy: matrix: - toolchain: [stable, nightly] + # toolchain: [stable, nightly] + toolchain: [nightly] target: [aarch64-apple-ios, x86_64-apple-ios, aarch64-apple-ios-sim] steps: - uses: actions/checkout@v4 @@ -47,7 +49,7 @@ jobs: - name: Build for iOS target ${{matrix.target}} run: cargo build --verbose --target=${{matrix.target}} - visionos-check: + apple-tier-3-check: # TBD: watchOS, tvOS runs-on: macOS-latest strategy: matrix: @@ -73,7 +75,8 @@ jobs: run: find /Applications/Xcode_15.4.app -name AudioUnit.h - name: Build for visionOS target ${{matrix.target}} - run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} + run: cargo build --verbose --target=${{matrix.target}} + # run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} # Build the docs with all features to make sure docs.rs will work. macos-docs: @@ -86,7 +89,8 @@ jobs: version: "15.0" - uses: dtolnay/rust-toolchain@master with: - toolchain: stable + # toolchain: stable + toolchain: nightly - name: cargo doc - all features run: cargo doc --all-features --verbose diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 2cf1049..ad306a7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,5 +2,6 @@ channel = "nightly" # channel = "stable" # components = ["rust-std", "rust-src", "rustc-dev", "llvm-tools-preview"] +profile = "minimal" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] targets = ["aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", "aarch64-apple-vision", "aarch64-apple-vision-sim"] \ No newline at end of file From 4dac4da83acba2937b6e0347ed30137c1bbccc4c Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:23:17 -0400 Subject: [PATCH 43/60] try default Xcode --- .github/workflows/coreaudio-sys.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index cecc903..8ea5963 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -64,15 +64,16 @@ jobs: components: rust-src - name: Install Xcode Command Line Tools - run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer - # run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + # run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md - name: Show Xcode SDKs run: xcodebuild -showsdks - name: Find AudioUnit.h - run: find /Applications/Xcode_15.4.app -name AudioUnit.h + # run: find /Applications/Xcode_15.4.app -name AudioUnit.h + run: find /Applications/Xcode.app -name AudioUnit.h - name: Build for visionOS target ${{matrix.target}} run: cargo build --verbose --target=${{matrix.target}} From 3eaa1923a72a1372ff1e5f789fa42926099501b2 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:31:02 -0400 Subject: [PATCH 44/60] target.contains("apple-visionos") --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 6d63f5d..404b4d3 100644 --- a/build.rs +++ b/build.rs @@ -60,13 +60,13 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios") || target.contains("apple-visionos"){ + 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"); headers.push("AudioToolbox/AudioUnit.h"); - } else { + } else if(!target.contains("apple-visionos")){ // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. // From 21ad6c52626244c2001803b6d332582ec7d61996 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:35:34 -0400 Subject: [PATCH 45/60] comment out audio_toolbox for visionos --- build.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 404b4d3..e6a6ca4 100644 --- a/build.rs +++ b/build.rs @@ -66,7 +66,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // The AudioToolbox framework contains the symbols instead. println!("cargo:rustc-link-lib=framework=AudioToolbox"); headers.push("AudioToolbox/AudioUnit.h"); - } else if(!target.contains("apple-visionos")){ + } else if !target.contains("apple-visionos") { // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. // @@ -81,8 +81,10 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "audio_toolbox")] { - println!("cargo:rustc-link-lib=framework=AudioToolbox"); - headers.push("AudioToolbox/AudioToolbox.h"); + if !target.contains("apple-visionos") { + println!("cargo:rustc-link-lib=framework=AudioToolbox"); + headers.push("AudioToolbox/AudioToolbox.h"); + } } #[cfg(feature = "core_audio")] From d9cf1358ef0e1dd4c7f75949dff4dcfc4bd1e949 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:39:46 -0400 Subject: [PATCH 46/60] temp comment out CoreAudioTypes for visionos --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index e6a6ca4..bd5329a 100644 --- a/build.rs +++ b/build.rs @@ -91,7 +91,7 @@ fn build(sdk_path: Option<&str>, target: &str) { { println!("cargo:rustc-link-lib=framework=CoreAudio"); - if target.contains("apple-ios") || target.contains("apple-visionos") { + if target.contains("apple-ios") || !target.contains("apple-visionos") { headers.push("CoreAudio/CoreAudioTypes.h"); } else { headers.push("CoreAudio/CoreAudio.h"); From 149d06c9d2108c9aa1954854ae8974c0492f9253 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:41:46 -0400 Subject: [PATCH 47/60] bump --- build.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index bd5329a..0bcbeb6 100644 --- a/build.rs +++ b/build.rs @@ -91,14 +91,16 @@ fn build(sdk_path: Option<&str>, target: &str) { { println!("cargo:rustc-link-lib=framework=CoreAudio"); - if target.contains("apple-ios") || !target.contains("apple-visionos") { - headers.push("CoreAudio/CoreAudioTypes.h"); - } else { - headers.push("CoreAudio/CoreAudio.h"); - - #[cfg(feature = "audio_server_plugin")] - { - headers.push("CoreAudio/AudioServerPlugIn.h"); + if !target.contains("apple-visionos") { + if target.contains("apple-ios") { + headers.push("CoreAudio/CoreAudioTypes.h"); + } else { + headers.push("CoreAudio/CoreAudio.h"); + + #[cfg(feature = "audio_server_plugin")] + { + headers.push("CoreAudio/AudioServerPlugIn.h"); + } } } } From 118ece569a879f1f51fa5d1a27ec7ad3f4536790 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:45:32 -0400 Subject: [PATCH 48/60] cargo +nightly build --- .github/workflows/coreaudio-sys.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 8ea5963..eff7b77 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -76,8 +76,8 @@ jobs: run: find /Applications/Xcode.app -name AudioUnit.h - name: Build for visionOS target ${{matrix.target}} - run: cargo build --verbose --target=${{matrix.target}} - # run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} + # run: cargo build --verbose --target=${{matrix.target}} + run: cargo +nightly build -Z build-std=std,panic_abort --verbose --target=${{matrix.target}} # Build the docs with all features to make sure docs.rs will work. macos-docs: From 51d5696326a57aa63b75ffc6159de79e7bbe01be Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:51:59 -0400 Subject: [PATCH 49/60] cargo fmt --- build.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index 0bcbeb6..f89695a 100644 --- a/build.rs +++ b/build.rs @@ -174,7 +174,6 @@ fn build(sdk_path: Option<&str>, target: &str) { .map(|h| format!("#include <{}>\n", h)) .collect(); - let fixes = if target.contains("apple-visionos") { vec![ // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:43:11: fatal error: 'AudioToolbox/AudioFileComponent.h' file not found @@ -182,16 +181,16 @@ fn build(sdk_path: Option<&str>, target: &str) { // https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.13.sdk/usr/include/MacTypes.h#L289 // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1633:8: error: unknown type name 'ItemCount' "typedef unsigned long ItemCount;\n", - "typedef unsigned long ByteCount;\n" + "typedef unsigned long ByteCount;\n", ] - }else { + } else { vec![""] }; let contents = format!("{}{}", fixes.concat(), meta_header.concat()); println!("============================="); - println!("{}",&contents); + println!("{}", &contents); println!("============================="); builder = builder.header_contents("coreaudio.h", &contents); @@ -209,7 +208,10 @@ fn build(sdk_path: Option<&str>, target: &str) { fn main() { let target = std::env::var("TARGET").unwrap(); - if !(target.contains("apple-darwin") || target.contains("apple-ios") || target.contains("apple-visionos")) { + if !(target.contains("apple-darwin") + || target.contains("apple-ios") + || target.contains("apple-visionos")) + { panic!("coreaudio-sys requires macos or ios or visionos target"); } From 90edab549990c1fbff98222d91e83ad071400a86 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:53:43 -0400 Subject: [PATCH 50/60] adding CoreAudio back to visionos --- build.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index f89695a..2732902 100644 --- a/build.rs +++ b/build.rs @@ -91,16 +91,14 @@ fn build(sdk_path: Option<&str>, target: &str) { { println!("cargo:rustc-link-lib=framework=CoreAudio"); - if !target.contains("apple-visionos") { - if target.contains("apple-ios") { - headers.push("CoreAudio/CoreAudioTypes.h"); - } else { - headers.push("CoreAudio/CoreAudio.h"); - - #[cfg(feature = "audio_server_plugin")] - { - headers.push("CoreAudio/AudioServerPlugIn.h"); - } + if target.contains("apple-ios") || target.contains("apple-visionos") { + headers.push("CoreAudio/CoreAudioTypes.h"); + } else { + headers.push("CoreAudio/CoreAudio.h"); + + #[cfg(feature = "audio_server_plugin")] + { + headers.push("CoreAudio/AudioServerPlugIn.h"); } } } From 872095d88bab9c6ec01ec20fba27d4692d1d5d42 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 15:55:19 -0400 Subject: [PATCH 51/60] AudioToolbox for visionOS --- build.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 2732902..9c06139 100644 --- a/build.rs +++ b/build.rs @@ -81,10 +81,8 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "audio_toolbox")] { - if !target.contains("apple-visionos") { - println!("cargo:rustc-link-lib=framework=AudioToolbox"); - headers.push("AudioToolbox/AudioToolbox.h"); - } + println!("cargo:rustc-link-lib=framework=AudioToolbox"); + headers.push("AudioToolbox/AudioToolbox.h"); } #[cfg(feature = "core_audio")] From fc5aec45720a33869a6f035762da5c6faac2402c Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 16:02:29 -0400 Subject: [PATCH 52/60] and AudioUnit.h again --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 9c06139..8d6c376 100644 --- a/build.rs +++ b/build.rs @@ -60,13 +60,13 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios") { + if target.contains("apple-ios") || target.contains("apple-visionos"){ // 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"); headers.push("AudioToolbox/AudioUnit.h"); - } else if !target.contains("apple-visionos") { + } else { // On macOS, the symbols are present in the AudioToolbox framework, // but only on macOS 10.12 and above. // From 7212e4d0181c54f7f485d6eab9c679b7c0547dad Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 16:06:44 -0400 Subject: [PATCH 53/60] arm64-apple-xros!!!! --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 8d6c376..292c2e3 100644 --- a/build.rs +++ b/build.rs @@ -138,7 +138,7 @@ fn build(sdk_path: Option<&str>, target: &str) { let target = if target == "aarch64-apple-ios" { "arm64-apple-ios" } else if target == "aarch64-apple-visionos" { - "arm64-apple-visionos" + "arm64-apple-xros" } else if target == "aarch64-apple-darwin" { "arm64-apple-darwin" } else { From b91dbb5a56dbd9d9dce42cd619a3a9180c1cb387 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 16:11:51 -0400 Subject: [PATCH 54/60] Xcode_15.4.app --- .github/workflows/coreaudio-sys.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index eff7b77..6ed43c7 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -64,16 +64,16 @@ jobs: components: rust-src - name: Install Xcode Command Line Tools - # run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer - run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer + # run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md - name: Show Xcode SDKs run: xcodebuild -showsdks - name: Find AudioUnit.h - # run: find /Applications/Xcode_15.4.app -name AudioUnit.h - run: find /Applications/Xcode.app -name AudioUnit.h + run: find /Applications/Xcode_15.4.app -name AudioUnit.h + # run: find /Applications/Xcode.app -name AudioUnit.h - name: Build for visionOS target ${{matrix.target}} # run: cargo build --verbose --target=${{matrix.target}} From 685c316bd907281c3a5aa76d9faa128488bf222e Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 16:16:35 -0400 Subject: [PATCH 55/60] include sim in the target --- build.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 292c2e3..f48783e 100644 --- a/build.rs +++ b/build.rs @@ -135,11 +135,11 @@ fn build(sdk_path: Option<&str>, target: &str) { // See https://github.com/rust-lang/rust-bindgen/issues/1211 // Technically according to the llvm mailing list, the argument to clang here should be // -arch arm64 but it looks cleaner to just change the target. - let target = if target == "aarch64-apple-ios" { + let target = if target.starts_with("aarch64-apple-ios") { "arm64-apple-ios" - } else if target == "aarch64-apple-visionos" { + } else if target.starts_with("aarch64-apple-visionos") { "arm64-apple-xros" - } else if target == "aarch64-apple-darwin" { + } else if target.starts_with("aarch64-apple-darwin") { "arm64-apple-darwin" } else { target From 623b16aa4785953185858537e013b03e5e4aabfd Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Thu, 6 Jun 2024 16:28:24 -0400 Subject: [PATCH 56/60] bringing back stable toolchain --- .github/workflows/coreaudio-sys.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coreaudio-sys.yml b/.github/workflows/coreaudio-sys.yml index 6ed43c7..1c5628a 100644 --- a/.github/workflows/coreaudio-sys.yml +++ b/.github/workflows/coreaudio-sys.yml @@ -6,10 +6,12 @@ jobs: runs-on: macOS-latest strategy: matrix: - # toolchain: [stable, nightly] - toolchain: [nightly] + toolchain: [stable, nightly] + # toolchain: [nightly] steps: - uses: actions/checkout@v4 + - name: remove rust-toolchain.toml + run: rm -rf rust-toolchain.toml - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 with: @@ -28,8 +30,8 @@ jobs: runs-on: macOS-14 strategy: matrix: - # toolchain: [stable, nightly] - toolchain: [nightly] + toolchain: [stable, nightly] + # toolchain: [nightly] target: [aarch64-apple-ios, x86_64-apple-ios, aarch64-apple-ios-sim] steps: - uses: actions/checkout@v4 @@ -37,7 +39,8 @@ jobs: with: toolchain: ${{ matrix.toolchain }} targets: ${{ matrix.target }} - + - name: remove rust-toolchain.toml + run: rm -rf rust-toolchain.toml - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.3 with: From 20876ab40988594d0c8642cdfab5c14842e811f7 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Sat, 8 Jun 2024 13:47:06 -0400 Subject: [PATCH 57/60] cleanup --- build.rs | 54 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/build.rs b/build.rs index f48783e..f39f180 100644 --- a/build.rs +++ b/build.rs @@ -60,7 +60,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // Since iOS 10.0, macOS 10.12, visionOS 1.0, all the functionality in AudioUnit // moved to AudioToolbox, and the AudioUnit headers have been simple // wrappers ever since. - if target.contains("apple-ios") || target.contains("apple-visionos"){ + if target.contains("apple-ios") || target.contains("apple-visionos") { // 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. @@ -76,7 +76,6 @@ fn build(sdk_path: Option<&str>, target: &str) { println!("cargo:rustc-link-lib=framework=AudioUnit"); headers.push("AudioUnit/AudioUnit.h"); } - // headers.push("AudioUnit/AudioUnit.h"); } #[cfg(feature = "audio_toolbox")] @@ -103,9 +102,10 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "io_kit_audio")] { - assert!(target.contains("apple-darwin")); - println!("cargo:rustc-link-lib=framework=IOKit"); - headers.push("IOKit/audio/IOAudioTypes.h"); + if target.contains("apple-darwin") { + println!("cargo:rustc-link-lib=framework=IOKit"); + headers.push("IOKit/audio/IOAudioTypes.h"); + } } #[cfg(feature = "open_al")] @@ -119,7 +119,7 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(all(feature = "core_midi"))] { - if target.contains("apple-darwin") { + if target.contains("apple-darwin") || target.contains("apple-visionos") { println!("cargo:rustc-link-lib=framework=CoreMIDI"); headers.push("CoreMIDI/CoreMIDI.h"); } @@ -135,7 +135,7 @@ fn build(sdk_path: Option<&str>, target: &str) { // See https://github.com/rust-lang/rust-bindgen/issues/1211 // Technically according to the llvm mailing list, the argument to clang here should be // -arch arm64 but it looks cleaner to just change the target. - let target = if target.starts_with("aarch64-apple-ios") { + let clang_target = if target.starts_with("aarch64-apple-ios") { "arm64-apple-ios" } else if target.starts_with("aarch64-apple-visionos") { "arm64-apple-xros" @@ -146,9 +146,7 @@ fn build(sdk_path: Option<&str>, target: &str) { }; builder = builder.size_t_is_usize(true); - builder = builder.clang_args(&[&format!("--target={}", target)]); - // idea from https://github.com/RustAudio/coreaudio-sys/issues/23#issuecomment-507364379 - // builder = builder.clang_args(&["-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework", "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk//usr/include"]); + builder = builder.clang_args(&[&format!("--target={}", clang_target)]); if let Some(sdk_path) = sdk_path { builder = builder.clang_args(&["-isysroot", sdk_path]); @@ -165,29 +163,27 @@ fn build(sdk_path: Option<&str>, target: &str) { // https://github.com/rust-lang/rust-bindgen/issues/1651 builder = builder.layout_tests(false); + if target.contains("apple-visionos") { + // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:43:11: fatal error: 'AudioToolbox/AudioFileComponent.h' file not found + headers.insert(0, "#define TARGET_OS_IPHONE 1"); + // https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.13.sdk/usr/include/MacTypes.h#L289 + // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1633:8: error: unknown type name 'ItemCount' + headers.insert(0, "typedef unsigned long ItemCount;"); + headers.insert(0, "typedef unsigned long ByteCount;"); + }; + let meta_header: Vec<_> = headers .iter() - .map(|h| format!("#include <{}>\n", h)) + .map(|h| { + if h.ends_with(".h") { + format!("#include <{}>\n", h) + } else { + format!("{}\n", h) + } + }) .collect(); - let fixes = if target.contains("apple-visionos") { - vec![ - // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:43:11: fatal error: 'AudioToolbox/AudioFileComponent.h' file not found - "#define TARGET_OS_IPHONE true\n", - // https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.13.sdk/usr/include/MacTypes.h#L289 - // /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1633:8: error: unknown type name 'ItemCount' - "typedef unsigned long ItemCount;\n", - "typedef unsigned long ByteCount;\n", - ] - } else { - vec![""] - }; - - let contents = format!("{}{}", fixes.concat(), meta_header.concat()); - - println!("============================="); - println!("{}", &contents); - println!("============================="); + let contents = meta_header.concat(); builder = builder.header_contents("coreaudio.h", &contents); From 3278affd9b2fe7fd5906cdd19b42cf584c3c5d11 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Sat, 8 Jun 2024 13:48:13 -0400 Subject: [PATCH 58/60] remove comments --- build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.rs b/build.rs index f39f180..ea4dd15 100644 --- a/build.rs +++ b/build.rs @@ -34,8 +34,6 @@ fn sdk_path(target: &str) -> Result { .stdout; let prefix_str = std::str::from_utf8(&output).expect("invalid output from `xcrun`"); - println!("COREAUDIO_SDK_PATH - {prefix_str}"); - Ok(prefix_str.trim_end().to_string()) } From 1d16260809496a7004a0201a7500d4dacf80b54a Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Sat, 8 Jun 2024 16:56:36 -0400 Subject: [PATCH 59/60] AudioToolbox/AudioSesssion.h fixes kAudioSessionProperty_CurrentHardwareIOBufferDuration --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index ea4dd15..8957678 100644 --- a/build.rs +++ b/build.rs @@ -80,6 +80,7 @@ fn build(sdk_path: Option<&str>, target: &str) { { println!("cargo:rustc-link-lib=framework=AudioToolbox"); headers.push("AudioToolbox/AudioToolbox.h"); + headers.push("AudioToolbox/AudioSession.h"); } #[cfg(feature = "core_audio")] From 17eaa7c2fb9b5cf81e3c09984c1c443c4b724635 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Sat, 8 Jun 2024 19:40:32 -0400 Subject: [PATCH 60/60] better clan target matcher --- build.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index 8957678..146c796 100644 --- a/build.rs +++ b/build.rs @@ -134,14 +134,12 @@ fn build(sdk_path: Option<&str>, target: &str) { // See https://github.com/rust-lang/rust-bindgen/issues/1211 // Technically according to the llvm mailing list, the argument to clang here should be // -arch arm64 but it looks cleaner to just change the target. - let clang_target = if target.starts_with("aarch64-apple-ios") { - "arm64-apple-ios" - } else if target.starts_with("aarch64-apple-visionos") { - "arm64-apple-xros" - } else if target.starts_with("aarch64-apple-darwin") { - "arm64-apple-darwin" - } else { - target + let clang_target = match target { + "aarch64-apple-ios" => "arm64-apple-ios", + "aarch64-apple-visionos" => "arm64-apple-xros", + "aarch64-apple-visionos-sim" => "arm64-apple-xros-sim", + "aarch64-apple-darwin" => "arm64-apple-darwin", + _ => target }; builder = builder.size_t_is_usize(true);