fn filename_parts(target: Option<&str>, cfg: &Config)
                      -> CargoResult<(Option<(String, String)>, Option<(String, String)>, String)> {
        let mut process = util::process(cfg.rustc());
        process.arg("-")
               .arg("--crate-name").arg("_")
               .arg("--crate-type").arg("dylib")
               .arg("--crate-type").arg("staticlib")
               .arg("--crate-type").arg("bin")
               .arg("--print=file-names")
               .env_remove("RUST_LOG");
        if let Some(s) = target {
            process.arg("--target").arg(s);
        };
        let output = try!(process.exec_with_output());

        let error = str::from_utf8(&output.stderr).unwrap();
        let output = str::from_utf8(&output.stdout).unwrap();
        let mut lines = output.lines();
        let nodylib = Regex::new("unsupported crate type.*dylib").unwrap();
        let nostaticlib = Regex::new("unsupported crate type.*staticlib").unwrap();
        let nobin = Regex::new("unsupported crate type.*bin").unwrap();
        let dylib = if nodylib.is_match(error) {
            None
        } else {
            let dylib_parts: Vec<&str> = lines.next().unwrap().trim()
                                              .split('_').collect();
            assert!(dylib_parts.len() == 2,
                    "rustc --print-file-name output has changed");
            Some((dylib_parts[0].to_string(), dylib_parts[1].to_string()))
        };
        let staticlib = if nostaticlib.is_match(error) {
            None
        } else {
            let staticlib_parts: Vec<&str> = lines.next().unwrap().trim()
                                              .split('_').collect();
            assert!(staticlib_parts.len() == 2,
                    "rustc --print-file-name output has changed");
            Some((staticlib_parts[0].to_string(), staticlib_parts[1].to_string()))
        };

        let exe_suffix = if nobin.is_match(error) {
            String::new()
        } else {
            lines.next().unwrap().trim()
                 .split('_').skip(1).next().unwrap().to_string()
        };
        Ok((dylib, staticlib, exe_suffix))
    }
/// Run `rustc` to discover the dylib prefix/suffix for the target
/// specified as well as the exe suffix
Run `rustc` to discover the dylib prefix/suffix for the target
specified as well as the exe suffix
Run ` rustc ` to discover the dylib prefix / suffix for the target specified as well as the exe suffix
fn filename_parts(target: Option<&str>, cfg: &Config)
                      -> CargoResult<(Option<(String, String)>, Option<(String, String)>, String)> {
        let mut process = util::process(cfg.rustc());
        process.arg("-")
               .arg("--crate-name").arg("_")
               .arg("--crate-type").arg("dylib")
               .arg("--crate-type").arg("staticlib")
               .arg("--crate-type").arg("bin")
               .arg("--print=file-names")
               .env_remove("RUST_LOG");
        if let Some(s) = target {
            process.arg("--target").arg(s);
        };
        let output = try!(process.exec_with_output());
        let error = str::from_utf8(&output.stderr).unwrap();
        let output = str::from_utf8(&output.stdout).unwrap();
        let mut lines = output.lines();
        let nodylib = Regex::new("unsupported crate type.*dylib").unwrap();
        let nostaticlib = Regex::new("unsupported crate type.*staticlib").unwrap();
        let nobin = Regex::new("unsupported crate type.*bin").unwrap();
        let dylib = if nodylib.is_match(error) {
            None
        } else {
            let dylib_parts: Vec<&str> = lines.next().unwrap().trim()
                                              .split('_').collect();
            assert!(dylib_parts.len() == 2,
                    "rustc --print-file-name output has changed");
            Some((dylib_parts[0].to_string(), dylib_parts[1].to_string()))
        };
        let staticlib = if nostaticlib.is_match(error) {
            None
        } else {
            let staticlib_parts: Vec<&str> = lines.next().unwrap().trim()
                                              .split('_').collect();
            assert!(staticlib_parts.len() == 2,
                    "rustc --print-file-name output has changed");
            Some((staticlib_parts[0].to_string(), staticlib_parts[1].to_string()))
        };
        let exe_suffix = if nobin.is_match(error) {
            String::new()
        } else {
            lines.next().unwrap().trim()
                 .split('_').skip(1).next().unwrap().to_string()
        };
        Ok((dylib, staticlib, exe_suffix))
    }
fn filename_parts ( target : Option < & str > , cfg : & Config ) -> CargoResult < ( Option < ( String , String ) > , Option < ( String , String ) > , String ) > { let mut process = util :: process ( cfg . rustc ( ) ) ; process . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . env_remove ( " " ) ; if let Some ( s ) = target { process . arg ( " " ) . arg ( s ) ; } ; let output = try ! ( process exec_with_output ( ) ) ; let error = str :: from_utf8 ( & output . stderr ) . unwrap ( ) ; let output = str :: from_utf8 ( & output . stdout ) . unwrap ( ) ; let mut lines = output . lines ( ) ; let nodylib = Regex :: new ( " " ) . unwrap ( ) ; let nostaticlib = Regex :: new ( " " ) . unwrap ( ) ; let nobin = Regex :: new ( " " ) . unwrap ( ) ; let dylib = if nodylib . is_match ( error ) { None } else { let dylib_parts : Vec < & str > = lines . next ( ) . unwrap ( ) . trim ( ) . split ( '_' ) . collect ( ) ; assert ! ( dylib_parts len ( ) 2 " " ) ; Some ( ( dylib_parts [ 0 ] . to_string ( ) , dylib_parts [ 1 ] . to_string ( ) ) ) } ; let staticlib = if nostaticlib . is_match ( error ) { None } else { let staticlib_parts : Vec < & str > = lines . next ( ) . unwrap ( ) . trim ( ) . split ( '_' ) . collect ( ) ; assert ! ( staticlib_parts len ( ) 2 " " ) ; Some ( ( staticlib_parts [ 0 ] . to_string ( ) , staticlib_parts [ 1 ] . to_string ( ) ) ) } ; let exe_suffix = if nobin . is_match ( error ) { String :: new ( ) } else { lines . next ( ) . unwrap ( ) . trim ( ) . split ( '_' ) . skip ( 1 ) . next ( ) . unwrap ( ) . to_string ( ) } ; Ok ( ( dylib , staticlib , exe_suffix ) ) }
Run `rustc` to discover the dylib prefix/suffix for the target
specified as well as the exe suffix
Run ` rustc ` to discover the dylib prefix / suffix for the target specified as well as the exe suffix
target
Option<&str>
cfg
&Config
target
Option<&str>
cfg
&Config