Skip to content

Commit 4c0062d

Browse files
authored
fix: Add apple tvos support (#881)
* fix: Add apple tvos support * ci: Add apple tvOS build job
1 parent fcedb00 commit 4c0062d

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ jobs:
9292
- run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --features parallel
9393
- run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --release
9494

95+
check-tvos:
96+
name: Test aarch64-apple-tvos
97+
runs-on: macos-latest
98+
steps:
99+
- uses: actions/checkout@v4
100+
- name: Install Rust (rustup)
101+
run: |
102+
set -euxo pipefail
103+
rustup toolchain install nightly --no-self-update --profile minimal
104+
rustup component add rust-src --toolchain nightly
105+
rustup default nightly
106+
shell: bash
107+
- run: cargo test -Z build-std=std --no-run --target aarch64-apple-tvos
108+
- run: cargo test -Z build-std=std --no-run --features parallel --target aarch64-apple-tvos
109+
- run: cargo test -Z build-std=std --no-run --manifest-path cc-test/Cargo.toml --target aarch64-apple-tvos
110+
- run: cargo test -Z build-std=std --no-run --manifest-path cc-test/Cargo.toml --target aarch64-apple-tvos --features parallel
111+
- run: cargo test -Z build-std=std --no-run --manifest-path cc-test/Cargo.toml --target aarch64-apple-tvos --release
112+
95113
cuda:
96114
name: Test CUDA support
97115
runs-on: ubuntu-20.04

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,16 @@ impl Build {
18311831
.into(),
18321832
);
18331833
}
1834+
} else if target.contains("aarch64-apple-tvos") {
1835+
if let Some(arch) =
1836+
map_darwin_target_from_rust_to_compiler_architecture(target)
1837+
{
1838+
let deployment_target =
1839+
self.apple_deployment_version(AppleOs::TvOs, target, None);
1840+
cmd.args.push(
1841+
format!("--target={}-apple-tvos{}", arch, deployment_target).into(),
1842+
);
1843+
}
18341844
} else if target.starts_with("riscv64gc-") {
18351845
cmd.args.push(
18361846
format!("--target={}", target.replace("riscv64gc", "riscv64")).into(),
@@ -2568,6 +2578,8 @@ impl Build {
25682578
clang.to_string()
25692579
} else if target.contains("apple-watchos") {
25702580
clang.to_string()
2581+
} else if target.contains("apple-tvos") {
2582+
clang.to_string()
25712583
} else if target.contains("android") {
25722584
autodetect_android_compiler(&target, &host, gnu, clang)
25732585
} else if target.contains("cloudabi") {

tests/support/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ impl Test {
6161
t
6262
}
6363

64+
pub fn clang() -> Test {
65+
let t = Test::new();
66+
t.shim("clang").shim("clang++").shim("ar");
67+
t
68+
}
69+
6470
pub fn shim(&self, name: &str) -> &Test {
6571
let name = if name.ends_with(env::consts::EXE_SUFFIX) {
6672
name.to_string()

tests/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,9 @@ fn gnu_apple_darwin() {
510510

511511
#[cfg(target_os = "macos")]
512512
#[test]
513-
fn apple_tvos() {
513+
fn clang_apple_tvos() {
514514
for target in &["aarch64-apple-tvos"] {
515-
let test = Test::gnu();
515+
let test = Test::clang();
516516
test.gcc()
517517
.target(&target)
518518
.host(&target)
@@ -525,9 +525,9 @@ fn apple_tvos() {
525525

526526
#[cfg(target_os = "macos")]
527527
#[test]
528-
fn apple_tvsimulator() {
528+
fn clang_apple_tvsimulator() {
529529
for target in &["x86_64-apple-tvos"] {
530-
let test = Test::gnu();
530+
let test = Test::clang();
531531
test.gcc()
532532
.target(&target)
533533
.host(&target)

0 commit comments

Comments
 (0)