Skip to content

Commit

Permalink
librustc: move target dependent logic to back::link
Browse files Browse the repository at this point in the history
  • Loading branch information
yichoi committed Jan 6, 2014
1 parent 19e97f5 commit c8c9942
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/librustc/back/archive.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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());
Expand Down
16 changes: 16 additions & 0 deletions src/librustc/back/link.rs
Expand Up @@ -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,
Expand Down

0 comments on commit c8c9942

Please sign in to comment.