Skip to content

Commit

Permalink
Added ios support
Browse files Browse the repository at this point in the history
  • Loading branch information
simlay committed Dec 31, 2019
1 parent 2082654 commit fcd554d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 14 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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]);
Expand Down

0 comments on commit fcd554d

Please sign in to comment.