Skip to content

Commit

Permalink
Merged apple_tvos_base and apple_ios_base into apple_sdk_base.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Imlay committed Feb 15, 2020
1 parent a266169 commit 6b17330
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 150 deletions.
4 changes: 2 additions & 2 deletions src/librustc_target/spec/aarch64_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_ios_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = opts(Arch::Arm64)?;
let base = opts(Arch::Arm64, AppleOS::iOS)?;
Ok(Target {
llvm_target: "arm64-apple-ios".to_string(),
target_endian: "little".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_target/spec/aarch64_apple_tvos.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_tvos_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = opts(Arch::Arm64)?;
let base = opts(Arch::Arm64, AppleOS::tvOS)?;
Ok(Target {
llvm_target: "arm64-apple-tvos".to_string(),
target_endian: "little".to_string(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
use std::env;
use std::io;
use std::path::Path;
use std::process::Command;

use Arch::*;

#[allow(non_camel_case_types)]
#[derive(Copy, Clone)]
pub enum Arch {
Expand All @@ -17,6 +17,13 @@ pub enum Arch {
X86_64_macabi,
}

#[allow(non_camel_case_types)]
#[derive(Copy, Clone)]
pub enum AppleOS {
tvOS,
iOS,
}

impl Arch {
pub fn to_string(self) -> &'static str {
match self {
Expand All @@ -41,6 +48,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
let p = Path::new(&sdkroot);
match sdk_name {
// Ignore `SDKROOT` if it's clearly set for the wrong platform.
"appletvos"
if sdkroot.contains("TVSimulator.platform")
|| sdkroot.contains("MacOSX.platform") =>
{
()
}
"appletvsimulator"
if sdkroot.contains("TVOS.platform") || sdkroot.contains("MacOSX.platform") =>
{
()
}
"iphoneos"
if sdkroot.contains("iPhoneSimulator.platform")
|| sdkroot.contains("MacOSX.platform") =>
Expand Down Expand Up @@ -82,11 +100,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
}
}

fn build_pre_link_args(arch: Arch) -> Result<LinkArgs, String> {
let sdk_name = match arch {
Armv7 | Armv7s | Arm64 => "iphoneos",
I386 | X86_64 => "iphonesimulator",
X86_64_macabi => "macosx10.15",
fn build_pre_link_args(arch: Arch, os: AppleOS) -> Result<LinkArgs, String> {
let sdk_name = match (arch, os) {
(Arm64, AppleOS::tvOS) => "appletvos",
(X86_64, AppleOS::tvOS) => "appletvsimulator",
(Armv7, AppleOS::iOS) => "iphoneos",
(Armv7s, AppleOS::iOS) => "iphoneos",
(Arm64, AppleOS::iOS) => "iphoneos",
(I386, AppleOS::iOS) => "iphonesimulator",
(X86_64, AppleOS::iOS) => "iphonesimulator",
(X86_64_macabi, AppleOS::iOS) => "macosx10.15",
_ => unreachable!(),
};

let arch_name = arch.to_string();
Expand Down Expand Up @@ -121,15 +145,16 @@ fn target_cpu(arch: Arch) -> String {
.to_string()
}


fn link_env_remove(arch: Arch) -> Vec<String> {
match arch {
Armv7 | Armv7s | Arm64 | I386 | X86_64 => vec!["MACOSX_DEPLOYMENT_TARGET".to_string()],
X86_64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".to_string()],
X86_64_macabi => vec![ "IPHONEOS_DEPLOYMENT_TARGET".to_string() ,],
}
}

pub fn opts(arch: Arch) -> Result<TargetOptions, String> {
let pre_link_args = build_pre_link_args(arch)?;
pub fn opts(arch: Arch, os: AppleOS) -> Result<TargetOptions, String> {
let pre_link_args = build_pre_link_args(arch, os)?;
Ok(TargetOptions {
cpu: target_cpu(arch),
dynamic_linking: false,
Expand Down
123 changes: 0 additions & 123 deletions src/librustc_target/spec/apple_tvos_base.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/librustc_target/spec/armv7_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_ios_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = opts(Arch::Armv7)?;
let base = opts(Arch::Armv7, AppleOS::iOS)?;
Ok(Target {
llvm_target: "armv7-apple-ios".to_string(),
target_endian: "little".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_target/spec/armv7s_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_ios_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = opts(Arch::Armv7s)?;
let base = opts(Arch::Armv7s, AppleOS::iOS)?;
Ok(Target {
llvm_target: "armv7s-apple-ios".to_string(),
target_endian: "little".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_target/spec/i386_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_ios_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = opts(Arch::I386)?;
let base = opts(Arch::I386, AppleOS::iOS)?;
Ok(Target {
llvm_target: "i386-apple-ios".to_string(),
target_endian: "little".to_string(),
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ use rustc_macros::HashStable_Generic;
pub mod abi;
mod android_base;
mod apple_base;
mod apple_ios_base;
mod apple_tvos_base;
mod apple_sdk_base;
mod arm_base;
mod cloudabi_base;
mod dragonfly_base;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_target/spec/x86_64_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_ios_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = opts(Arch::X86_64)?;
let base = opts(Arch::X86_64, AppleOS::iOS)?;
Ok(Target {
llvm_target: "x86_64-apple-ios".to_string(),
target_endian: "little".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_target/spec/x86_64_apple_ios_macabi.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_ios_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = opts(Arch::X86_64_macabi)?;
let base = opts(Arch::X86_64_macabi, AppleOS::iOS)?;
Ok(Target {
llvm_target: "x86_64-apple-ios13.0-macabi".to_string(),
target_endian: "little".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_target/spec/x86_64_apple_tvos.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::apple_tvos_base::{opts, Arch};
use super::apple_sdk_base::{opts, Arch, AppleOS};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

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

0 comments on commit 6b17330

Please sign in to comment.