Skip to content

fix to support android cross compile on mac #10900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc/back/archive.rs
Original file line number Diff line number Diff line change
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,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);
Expand Down
33 changes: 28 additions & 5 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

Expand Down