Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add apple tvos support #881

Merged
merged 2 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ jobs:
- run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --features parallel
- run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --release

check-tvos:
name: Test aarch64-apple-tvos
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (rustup)
run: |
set -euxo pipefail
rustup toolchain install nightly --no-self-update --profile minimal
rustup component add rust-src --toolchain nightly
rustup default nightly
shell: bash
- run: cargo test -Z build-std=std --no-run --target aarch64-apple-tvos
- run: cargo test -Z build-std=std --no-run --features parallel --target aarch64-apple-tvos
- run: cargo test -Z build-std=std --no-run --manifest-path cc-test/Cargo.toml --target aarch64-apple-tvos
- run: cargo test -Z build-std=std --no-run --manifest-path cc-test/Cargo.toml --target aarch64-apple-tvos --features parallel
- run: cargo test -Z build-std=std --no-run --manifest-path cc-test/Cargo.toml --target aarch64-apple-tvos --release

cuda:
name: Test CUDA support
runs-on: ubuntu-20.04
Expand Down
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,16 @@ impl Build {
.into(),
);
}
} else if target.contains("aarch64-apple-tvos") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
{
let deployment_target =
self.apple_deployment_version(AppleOs::TvOs, target, None);
cmd.args.push(
format!("--target={}-apple-tvos{}", arch, deployment_target).into(),
);
}
} else if target.starts_with("riscv64gc-") {
cmd.args.push(
format!("--target={}", target.replace("riscv64gc", "riscv64")).into(),
Expand Down Expand Up @@ -2577,6 +2587,8 @@ impl Build {
clang.to_string()
} else if target.contains("apple-watchos") {
clang.to_string()
} else if target.contains("apple-tvos") {
clang.to_string()
} else if target.contains("android") {
autodetect_android_compiler(&target, &host, gnu, clang)
} else if target.contains("cloudabi") {
Expand Down
6 changes: 6 additions & 0 deletions tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ impl Test {
t
}

pub fn clang() -> Test {
let t = Test::new();
t.shim("clang").shim("clang++").shim("ar");
t
}

pub fn shim(&self, name: &str) -> &Test {
let name = if name.ends_with(env::consts::EXE_SUFFIX) {
name.to_string()
Expand Down
8 changes: 4 additions & 4 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,9 @@ fn gnu_apple_darwin() {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests didn't require GCC, just check that the target-specific stuff works. They shouldn't be deleted.

There should also be a test that clang works and has everything set appropriately.

#[cfg(target_os = "macos")]
#[test]
fn apple_tvos() {
fn clang_apple_tvos() {
for target in &["aarch64-apple-tvos"] {
let test = Test::gnu();
let test = Test::clang();
test.gcc()
.target(&target)
.host(&target)
Expand All @@ -525,9 +525,9 @@ fn apple_tvos() {

#[cfg(target_os = "macos")]
#[test]
fn apple_tvsimulator() {
fn clang_apple_tvsimulator() {
for target in &["x86_64-apple-tvos"] {
let test = Test::gnu();
let test = Test::clang();
test.gcc()
.target(&target)
.host(&target)
Expand Down