From e6490cbdb01dfa8687d29c42ac3e7342ff2bafaf Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Thu, 2 Jan 2014 15:43:47 +0900 Subject: [PATCH] librustc: add get_system_tools for target specific environment --- src/librustc/back/link.rs | 41 +++++++++++++++++++++++---------------- 1 file 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