From 2ca1fe0747b90511395ca5027698f5d70189d68b Mon Sep 17 00:00:00 2001 From: Luis Cruz Date: Mon, 10 Jul 2023 16:41:49 +0100 Subject: [PATCH] fix: Add apple tvos support --- src/lib.rs | 16 ++++++++++++++++ tests/support/mod.rs | 6 ++++++ tests/test.rs | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 77f1a1db1..2e11659d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1840,6 +1840,20 @@ 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(), @@ -2577,6 +2591,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") { diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 3ec191113..bf0c912dd 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -61,6 +61,12 @@ impl Test { t } + pub fn darwin() -> 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() diff --git a/tests/test.rs b/tests/test.rs index f712c4368..b8670de02 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -512,7 +512,7 @@ fn gnu_apple_darwin() { #[test] fn apple_tvos() { for target in &["aarch64-apple-tvos"] { - let test = Test::gnu(); + let test = Test::darwin(); test.gcc() .target(&target) .host(&target) @@ -527,7 +527,7 @@ fn apple_tvos() { #[test] fn apple_tvsimulator() { for target in &["x86_64-apple-tvos"] { - let test = Test::gnu(); + let test = Test::darwin(); test.gcc() .target(&target) .host(&target)