Skip to content

Commit 6b17330

Browse files
author
Sebastian Imlay
committed
Merged apple_tvos_base and apple_ios_base into apple_sdk_base.
1 parent a266169 commit 6b17330

11 files changed

+51
-150
lines changed

src/librustc_target/spec/aarch64_apple_ios.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_ios_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::Arm64)?;
5+
let base = opts(Arch::Arm64, AppleOS::iOS)?;
66
Ok(Target {
77
llvm_target: "arm64-apple-ios".to_string(),
88
target_endian: "little".to_string(),

src/librustc_target/spec/aarch64_apple_tvos.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_tvos_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::Arm64)?;
5+
let base = opts(Arch::Arm64, AppleOS::tvOS)?;
66
Ok(Target {
77
llvm_target: "arm64-apple-tvos".to_string(),
88
target_endian: "little".to_string(),

src/librustc_target/spec/apple_ios_base.rs renamed to src/librustc_target/spec/apple_sdk_base.rs

+34-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
12
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
23
use std::env;
34
use std::io;
45
use std::path::Path;
56
use std::process::Command;
67

78
use Arch::*;
8-
99
#[allow(non_camel_case_types)]
1010
#[derive(Copy, Clone)]
1111
pub enum Arch {
@@ -17,6 +17,13 @@ pub enum Arch {
1717
X86_64_macabi,
1818
}
1919

20+
#[allow(non_camel_case_types)]
21+
#[derive(Copy, Clone)]
22+
pub enum AppleOS {
23+
tvOS,
24+
iOS,
25+
}
26+
2027
impl Arch {
2128
pub fn to_string(self) -> &'static str {
2229
match self {
@@ -41,6 +48,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
4148
let p = Path::new(&sdkroot);
4249
match sdk_name {
4350
// Ignore `SDKROOT` if it's clearly set for the wrong platform.
51+
"appletvos"
52+
if sdkroot.contains("TVSimulator.platform")
53+
|| sdkroot.contains("MacOSX.platform") =>
54+
{
55+
()
56+
}
57+
"appletvsimulator"
58+
if sdkroot.contains("TVOS.platform") || sdkroot.contains("MacOSX.platform") =>
59+
{
60+
()
61+
}
4462
"iphoneos"
4563
if sdkroot.contains("iPhoneSimulator.platform")
4664
|| sdkroot.contains("MacOSX.platform") =>
@@ -82,11 +100,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
82100
}
83101
}
84102

85-
fn build_pre_link_args(arch: Arch) -> Result<LinkArgs, String> {
86-
let sdk_name = match arch {
87-
Armv7 | Armv7s | Arm64 => "iphoneos",
88-
I386 | X86_64 => "iphonesimulator",
89-
X86_64_macabi => "macosx10.15",
103+
fn build_pre_link_args(arch: Arch, os: AppleOS) -> Result<LinkArgs, String> {
104+
let sdk_name = match (arch, os) {
105+
(Arm64, AppleOS::tvOS) => "appletvos",
106+
(X86_64, AppleOS::tvOS) => "appletvsimulator",
107+
(Armv7, AppleOS::iOS) => "iphoneos",
108+
(Armv7s, AppleOS::iOS) => "iphoneos",
109+
(Arm64, AppleOS::iOS) => "iphoneos",
110+
(I386, AppleOS::iOS) => "iphonesimulator",
111+
(X86_64, AppleOS::iOS) => "iphonesimulator",
112+
(X86_64_macabi, AppleOS::iOS) => "macosx10.15",
113+
_ => unreachable!(),
90114
};
91115

92116
let arch_name = arch.to_string();
@@ -121,15 +145,16 @@ fn target_cpu(arch: Arch) -> String {
121145
.to_string()
122146
}
123147

148+
124149
fn link_env_remove(arch: Arch) -> Vec<String> {
125150
match arch {
126151
Armv7 | Armv7s | Arm64 | I386 | X86_64 => vec!["MACOSX_DEPLOYMENT_TARGET".to_string()],
127-
X86_64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".to_string()],
152+
X86_64_macabi => vec![ "IPHONEOS_DEPLOYMENT_TARGET".to_string() ,],
128153
}
129154
}
130155

131-
pub fn opts(arch: Arch) -> Result<TargetOptions, String> {
132-
let pre_link_args = build_pre_link_args(arch)?;
156+
pub fn opts(arch: Arch, os: AppleOS) -> Result<TargetOptions, String> {
157+
let pre_link_args = build_pre_link_args(arch, os)?;
133158
Ok(TargetOptions {
134159
cpu: target_cpu(arch),
135160
dynamic_linking: false,

src/librustc_target/spec/apple_tvos_base.rs

-123
This file was deleted.

src/librustc_target/spec/armv7_apple_ios.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_ios_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::Armv7)?;
5+
let base = opts(Arch::Armv7, AppleOS::iOS)?;
66
Ok(Target {
77
llvm_target: "armv7-apple-ios".to_string(),
88
target_endian: "little".to_string(),

src/librustc_target/spec/armv7s_apple_ios.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_ios_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::Armv7s)?;
5+
let base = opts(Arch::Armv7s, AppleOS::iOS)?;
66
Ok(Target {
77
llvm_target: "armv7s-apple-ios".to_string(),
88
target_endian: "little".to_string(),

src/librustc_target/spec/i386_apple_ios.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_ios_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::I386)?;
5+
let base = opts(Arch::I386, AppleOS::iOS)?;
66
Ok(Target {
77
llvm_target: "i386-apple-ios".to_string(),
88
target_endian: "little".to_string(),

src/librustc_target/spec/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ use rustc_macros::HashStable_Generic;
4747
pub mod abi;
4848
mod android_base;
4949
mod apple_base;
50-
mod apple_ios_base;
51-
mod apple_tvos_base;
50+
mod apple_sdk_base;
5251
mod arm_base;
5352
mod cloudabi_base;
5453
mod dragonfly_base;

src/librustc_target/spec/x86_64_apple_ios.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_ios_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::X86_64)?;
5+
let base = opts(Arch::X86_64, AppleOS::iOS)?;
66
Ok(Target {
77
llvm_target: "x86_64-apple-ios".to_string(),
88
target_endian: "little".to_string(),

src/librustc_target/spec/x86_64_apple_ios_macabi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_ios_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::X86_64_macabi)?;
5+
let base = opts(Arch::X86_64_macabi, AppleOS::iOS)?;
66
Ok(Target {
77
llvm_target: "x86_64-apple-ios13.0-macabi".to_string(),
88
target_endian: "little".to_string(),

src/librustc_target/spec/x86_64_apple_tvos.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use super::apple_tvos_base::{opts, Arch};
1+
use super::apple_sdk_base::{opts, Arch, AppleOS};
22
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
33

44
pub fn target() -> TargetResult {
5-
let base = opts(Arch::X86_64)?;
5+
let base = opts(Arch::X86_64, AppleOS::iOS)?;
66
Ok(Target {
77
llvm_target: "x86_64-apple-tvos".to_string(),
88
target_endian: "little".to_string(),

0 commit comments

Comments
 (0)