librustc: add get_system_tools for target specific environment

This commit is contained in:
Young-il Choi 2014-01-02 15:43:47 +09:00
parent c8c99429d2
commit e6490cbdb0

View File

@ -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