about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-01-05 20:56:53 -0800
committerbors <bors@rust-lang.org>2014-01-05 20:56:53 -0800
commita6d3e57dca68fde4effdda3e4ae2887aa535fcd6 (patch)
tree3a4f3b004615b1c4faa7c6503aa6f1e9396da1d2 /src
parentcdcf28dd30d0f8505deae147e1dfe21120a3b8f3 (diff)
parent635002a3503b1020433f729dbb5b37e30a691813 (diff)
downloadrust-a6d3e57dca68fde4effdda3e4ae2887aa535fcd6.tar.gz
rust-a6d3e57dca68fde4effdda3e4ae2887aa535fcd6.zip
auto merge of #10900 : yichoi/rust/mac_android_cross, r=alexcrichton
this patch should be followed by https://github.com/alexcrichton/libuv/pull/2

Diffstat (limited to 'src')
-rw-r--r--src/librustc/back/archive.rs4
-rw-r--r--src/librustc/back/link.rs33
2 files changed, 31 insertions, 6 deletions
diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs
index 07457b1db27..cc96bea9fa1 100644
--- a/src/librustc/back/archive.rs
+++ b/src/librustc/back/archive.rs
@@ -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);
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index a63d0041d0c..a73c3cf6b5c 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -724,15 +724,38 @@ pub fn get_cc_prog(sess: Session) -> ~str {
     // 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(),
     }
 }