auto merge of #10900 : yichoi/rust/mac_android_cross, r=alexcrichton

this patch should be followed by https://github.com/alexcrichton/libuv/pull/2
This commit is contained in:
bors 2014-01-05 20:56:53 -08:00
commit a6d3e57dca
2 changed files with 31 additions and 6 deletions

View File

@ -10,6 +10,7 @@
//! A helper class for dealing with static archives
use back::link::{get_ar_prog};
use driver::session::Session;
use metadata::filesearch;
use lib::llvm::{ArchiveRef, llvm};
@ -37,7 +38,8 @@ pub struct ArchiveRO {
fn run_ar(sess: Session, args: &str, cwd: Option<&Path>,
paths: &[&Path]) -> ProcessOutput {
let ar = sess.opts.ar.clone().unwrap_or_else(|| ~"ar");
let ar = get_ar_prog(sess);
let mut args = ~[args.to_owned()];
let mut paths = paths.iter().map(|p| p.as_str().unwrap().to_owned());
args.extend(&mut paths);

View File

@ -723,16 +723,39 @@ pub fn get_cc_prog(sess: Session) -> ~str {
// It would be flexible to use cc (system's default C compiler)
// instead of hard-coded gcc.
// For win32, there is no cc command, so we add a condition to make it use gcc.
match sess.targ_cfg.os {
abi::OsWin32 => return ~"gcc",
_ => {},
}
get_system_tool(sess, "cc")
}
pub fn get_ar_prog(sess: Session) -> ~str {
match sess.opts.ar {
Some(ref ar) => return ar.to_owned(),
None => {}
}
get_system_tool(sess, "ar")
}
fn get_system_tool(sess: Session, tool: &str) -> ~str {
match sess.targ_cfg.os {
abi::OsAndroid => match sess.opts.android_cross_path {
Some(ref path) => format!("{}/bin/arm-linux-androideabi-gcc", *path),
Some(ref path) => {
let tool_str = match tool {
"cc" => "gcc",
_ => tool
};
format!("{}/bin/arm-linux-androideabi-{}", *path, tool_str)
}
None => {
sess.fatal("need Android NDK path for linking \
(--android-cross-path)")
sess.fatal(format!("need Android NDK path for the '{}' tool \
(--android-cross-path)", tool))
}
},
abi::OsWin32 => ~"gcc",
_ => ~"cc",
_ => tool.to_owned(),
}
}