about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYoung-il Choi <duddlf.choi@samsung.com>2014-01-02 15:43:47 +0900
committerYoung-il Choi <duddlf.choi@samsung.com>2014-01-06 13:04:26 +0900
commite6490cbdb01dfa8687d29c42ac3e7342ff2bafaf (patch)
treeddf6f478c2e0b14b5741f3bb4535f0c93d4471b0
parentc8c99429d2d40e70824dae90305acae88a3d917d (diff)
downloadrust-e6490cbdb01dfa8687d29c42ac3e7342ff2bafaf.tar.gz
rust-e6490cbdb01dfa8687d29c42ac3e7342ff2bafaf.zip
librustc: add get_system_tools for target specific environment
-rw-r--r--src/librustc/back/link.rs41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index a0364101d3d..414978df1db 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -724,32 +724,39 @@ 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::OsAndroid => match sess.opts.android_cross_path {
-            Some(ref path) => format!("{}/bin/arm-linux-androideabi-gcc", *path),
-            None => {
-                sess.fatal("need Android NDK path for linking \
-                            (--android-cross-path)")
-            }
-        },
-        abi::OsWin32 => ~"gcc",
-        _ => ~"cc",
+        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-ar", *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))
             }
         },
-        _ => match sess.opts.ar {
-            Some(ref ar) => format!("{}", *ar),
-            None => ~"ar"
-        },
-    }
+        _ => tool.to_owned(),
+    } 
 }
 
 /// Perform the linkage portion of the compilation phase. This will generate all