]> git.lizzy.rs Git - rust.git/commitdiff
librustc: move target dependent logic to back::link
authorYoung-il Choi <duddlf.choi@samsung.com>
Fri, 27 Dec 2013 08:29:53 +0000 (17:29 +0900)
committerYoung-il Choi <duddlf.choi@samsung.com>
Mon, 6 Jan 2014 04:04:26 +0000 (13:04 +0900)
src/librustc/back/archive.rs
src/librustc/back/link.rs

index e7535d8199dfe5564b6472a5b43d59d1e2251167..cc96bea9fa1b14bd6b02c5287eb46d99b0da31b2 100644 (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,14 +38,7 @@ pub struct ArchiveRO {
 
 fn run_ar(sess: Session, args: &str, cwd: Option<&Path>,
         paths: &[&Path]) -> ProcessOutput {
-    let ar = if sess.opts.target_triple == ~"arm-linux-androideabi" {
-        match sess.opts.android_cross_path {
-            Some(ref path) => *path + "/bin/" + "arm-linux-androideabi-ar",
-            None => ~"arm-linux-androideabi-ar"
-        }
-    } else {
-        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());
index a63d0041d0cb940ff4b9b9026d1233e41f8fd2a5..a0364101d3debe423d5bfa5ad4dbb841e28cf53c 100644 (file)
@@ -736,6 +736,22 @@ pub fn get_cc_prog(sess: Session) -> ~str {
     }
 }
 
+pub fn get_ar_prog(sess: Session) -> ~str {
+    match sess.targ_cfg.os {
+        abi::OsAndroid => match sess.opts.android_cross_path {
+            Some(ref path) => format!("{}/bin/arm-linux-androideabi-ar", *path),
+            None => {
+                sess.fatal("need Android NDK path for linking \
+                            (--android-cross-path)")
+            }
+        },
+        _ => match sess.opts.ar {
+            Some(ref ar) => format!("{}", *ar),
+            None => ~"ar"
+        },
+    }
+}
+
 /// Perform the linkage portion of the compilation phase. This will generate all
 /// of the requested outputs for this compilation session.
 pub fn link_binary(sess: Session,