pub fn parse(input: &str, pkg_name: &str) -> CargoResult<BuildOutput> {
        let mut library_paths = Vec::new();
        let mut library_links = Vec::new();
        let mut cfgs = Vec::new();
        let mut metadata = Vec::new();
        let mut rerun_if_changed = Vec::new();
        let whence = format!("build script of `{}`", pkg_name);

        for line in input.lines() {
            let mut iter = line.splitn(2, ':');
            if iter.next() != Some("cargo") {
                // skip this line since it doesn't start with "cargo:"
                continue;
            }
            let data = match iter.next() {
                Some(val) => val,
                None => continue
            };

            // getting the `key=value` part of the line
            let mut iter = data.splitn(2, '=');
            let key = iter.next();
            let value = iter.next();
            let (key, value) = match (key, value) {
                (Some(a), Some(b)) => (a, b.trim_right()),
                // line started with `cargo:` but didn't match `key=value`
                _ => bail!("Wrong output in {}: `{}`", whence, line),
            };

            match key {
                "rustc-flags" => {
                    let (libs, links) = try!(
                        BuildOutput::parse_rustc_flags(value, &whence)
                    );
                    library_links.extend(links.into_iter());
                    library_paths.extend(libs.into_iter());
                }
                "rustc-link-lib" => library_links.push(value.to_string()),
                "rustc-link-search" => library_paths.push(PathBuf::from(value)),
                "rustc-cfg" => cfgs.push(value.to_string()),
                "rerun-if-changed" => rerun_if_changed.push(value.to_string()),
                _ => metadata.push((key.to_string(), value.to_string())),
            }
        }

        Ok(BuildOutput {
            library_paths: library_paths,
            library_links: library_links,
            cfgs: cfgs,
            metadata: metadata,
            rerun_if_changed: rerun_if_changed,
        })
    }
// Parses the output of a script.
// The `pkg_name` is used for error messages.
Parses the output of a script.
The `pkg_name` is used for error messages.
Parses the output of a script . The ` pkg_name ` is used for error messages .
pub fn parse(input: &str, pkg_name: &str) -> CargoResult<BuildOutput> {
        let mut library_paths = Vec::new();
        let mut library_links = Vec::new();
        let mut cfgs = Vec::new();
        let mut metadata = Vec::new();
        let mut rerun_if_changed = Vec::new();
        let whence = format!("build script of `{}`", pkg_name);
        for line in input.lines() {
            let mut iter = line.splitn(2, ':');
            if iter.next() != Some("cargo") {
                // skip this line since it doesn't start with "cargo:"
                continue;
            }
            let data = match iter.next() {
                Some(val) => val,
                None => continue
            };
            // getting the `key=value` part of the line
            let mut iter = data.splitn(2, '=');
            let key = iter.next();
            let value = iter.next();
            let (key, value) = match (key, value) {
                (Some(a), Some(b)) => (a, b.trim_right()),
                // line started with `cargo:` but didn't match `key=value`
                _ => bail!("Wrong output in {}: `{}`", whence, line),
            };
            match key {
                "rustc-flags" => {
                    let (libs, links) = try!(
                        BuildOutput::parse_rustc_flags(value, &whence)
                    );
                    library_links.extend(links.into_iter());
                    library_paths.extend(libs.into_iter());
                }
                "rustc-link-lib" => library_links.push(value.to_string()),
                "rustc-link-search" => library_paths.push(PathBuf::from(value)),
                "rustc-cfg" => cfgs.push(value.to_string()),
                "rerun-if-changed" => rerun_if_changed.push(value.to_string()),
                _ => metadata.push((key.to_string(), value.to_string())),
            }
        }
        Ok(BuildOutput {
            library_paths: library_paths,
            library_links: library_links,
            cfgs: cfgs,
            metadata: metadata,
            rerun_if_changed: rerun_if_changed,
        })
    }
pub fn parse ( input : & str , pkg_name : & str ) -> CargoResult < BuildOutput > { let mut library_paths = Vec :: new ( ) ; let mut library_links = Vec :: new ( ) ; let mut cfgs = Vec :: new ( ) ; let mut metadata = Vec :: new ( ) ; let mut rerun_if_changed = Vec :: new ( ) ; let whence = format ! ( " " pkg_name ) ; for line in input . lines ( ) { let mut iter = line . splitn ( 2 , ':' ) ; if iter . next ( ) != Some ( " " ) { // skip this line since it doesn't start with "cargo:" continue ; } let data = match iter . next ( ) { Some ( val ) => val , None => continue } ; // getting the `key=value` part of the line let mut iter = data . splitn ( 2 , '=' ) ; let key = iter . next ( ) ; let value = iter . next ( ) ; let ( key , value ) = match ( key , value ) { ( Some ( a ) , Some ( b ) ) => ( a , b . trim_right ( ) ) , // line started with `cargo:` but didn't match `key=value` _ => bail ! ( " " whence line ) , } ; match key { " " => { let ( libs , links ) = try ! ( BuildOutput parse_rustc_flags ( value whence ) ) ; library_links . extend ( links . into_iter ( ) ) ; library_paths . extend ( libs . into_iter ( ) ) ; } " " => library_links . push ( value . to_string ( ) ) , " " => library_paths . push ( PathBuf :: from ( value ) ) , " " => cfgs . push ( value . to_string ( ) ) , " " => rerun_if_changed . push ( value . to_string ( ) ) , _ => metadata . push ( ( key . to_string ( ) , value . to_string ( ) ) ) , } } Ok ( BuildOutput { library_paths : library_paths , library_links : library_links , cfgs : cfgs , metadata : metadata , rerun_if_changed : rerun_if_changed , } ) }
Parses the output of a script.
Parses the output of a script .
input
&str
pkg_name
&str
input
&str
pkg_name
&str