From fcd554d7b418c0c533b4f7408ab52bdfafc9059c Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Tue, 31 Dec 2019 10:48:57 -0800 Subject: [PATCH] Added ios support --- .travis.yml | 3 ++- build.rs | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index eea814f..d87bf08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,6 @@ before_script: - if [ "$TRAVIS_OS_NAME" = linux ]; then rustup target add x86_64-apple-darwin; fi script: - if [ "$TRAVIS_OS_NAME" = linux ]; then curl -sL https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.13.sdk.tar.xz | tar -Jxf -; export COREAUDIO_SDK_PATH="$PWD/MacOSX10.13.sdk"; fi -- RUSTFMT=rustfmt cargo build --verbose --target=x86_64-apple-darwin +- rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios +- for i in x86_64-apple-darwin aarch64-apple-ios armv7-apple-ios armv7s-apple-ios; do RUSTFMT=rustfmt cargo build --verbose --target=$i; done - if [ "$TRAVIS_OS_NAME" = osx ]; then RUSTFMT=rustfmt cargo test --verbose; fi diff --git a/build.rs b/build.rs index 2b511e0..dad3234 100644 --- a/build.rs +++ b/build.rs @@ -54,7 +54,12 @@ fn build(sdk_path: Option<&str>, target: &str) { #[cfg(feature = "core_audio")] { println!("cargo:rustc-link-lib=framework=CoreAudio"); - headers.push("CoreAudio/CoreAudio.h"); + + if target.contains("apple-ios") { + headers.push("CoreAudio/CoreAudioTypes.h"); + } else { + headers.push("CoreAudio/CoreAudio.h"); + } } #[cfg(feature = "open_al")] @@ -79,7 +84,14 @@ fn build(sdk_path: Option<&str>, target: &str) { // Begin building the bindgen params. let mut builder = bindgen::Builder::default(); - builder = builder.clang_args(&[&format!("--target={}", target)]); + if target == "aarch64-apple-ios" { + // 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. + builder = builder.clang_args(&[&format!("--target={}", "arm64-apple-ios")]); + } else { + builder = builder.clang_args(&[&format!("--target={}", target)]); + } if let Some(sdk_path) = sdk_path { builder = builder.clang_args(&["-isysroot", sdk_path]);