]>
git.proxmox.com Git - rustc.git/blob - src/librustc_back/target/apple_ios_base.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use std
::process
::Command
;
13 use target
::TargetOptions
;
17 #[allow(non_camel_case_types)]
18 #[derive(Copy, Clone)]
28 pub fn to_string(&self) -> &'
static str {
39 pub fn get_sdk_root(sdk_name
: &str) -> String
{
40 let res
= Command
::new("xcrun")
41 .arg("--show-sdk-path")
46 if output
.status
.success() {
47 Ok(String
::from_utf8(output
.stdout
).unwrap())
49 let error
= String
::from_utf8(output
.stderr
);
50 let error
= format
!("process exit with error: {}",
52 Err(io
::Error
::new(io
::ErrorKind
::Other
,
58 Ok(output
) => output
.trim().to_string(),
59 Err(e
) => panic
!("failed to get {} SDK path: {}", sdk_name
, e
)
63 fn pre_link_args(arch
: Arch
) -> Vec
<String
> {
64 let sdk_name
= match arch
{
65 Armv7
| Armv7s
| Arm64
=> "iphoneos",
66 I386
| X86_64
=> "iphonesimulator"
69 let arch_name
= arch
.to_string();
71 vec
!["-arch".to_string(), arch_name
.to_string(),
72 "-Wl,-syslibroot".to_string(), get_sdk_root(sdk_name
)]
75 fn target_cpu(arch
: Arch
) -> String
{
77 Armv7
=> "cortex-a8", // iOS7 is supported on iPhone 4 and higher
78 Armv7s
=> "cortex-a9",
85 pub fn opts(arch
: Arch
) -> TargetOptions
{
87 cpu
: target_cpu(arch
),
88 dynamic_linking
: false,
90 pre_link_args
: pre_link_args(arch
),
92 .. super::apple_base
::opts()