fn build<'a, 'b, 'cfg>(out: &'a mut HashMap<Unit<'b>, BuildScripts>,
                           cx: &Context<'b, 'cfg>,
                           unit: &Unit<'b>)
                           -> &'a BuildScripts {
        // Do a quick pre-flight check to see if we've already calculated the
        // set of dependencies.
        if out.contains_key(unit) {
            return &out[unit]
        }

        let mut to_link = BTreeSet::new();
        let mut plugins = BTreeSet::new();

        if !unit.target.is_custom_build() && unit.pkg.has_custom_build() {
            to_link.insert((unit.pkg.package_id().clone(), unit.kind));
        }
        for unit in cx.dep_targets(unit).iter() {
            let dep_scripts = build(out, cx, unit);

            if unit.target.for_host() {
                plugins.extend(dep_scripts.to_link.iter()
                                          .map(|p| &p.0).cloned());
            } else if unit.target.linkable() {
                to_link.extend(dep_scripts.to_link.iter().cloned());
            }
        }

        let prev = out.entry(*unit).or_insert(BuildScripts::default());
        prev.to_link.extend(to_link);
        prev.plugins.extend(plugins);
        prev
    }
// Recursive function to build up the map we're constructing. This function
// memoizes all of its return values as it goes along.
Recursive function to build up the map we're constructing. This function
memoizes all of its return values as it goes along.
Recursive function to build up the map we ' re constructing . This function memoizes all of its return values as it goes along .
fn build<'a, 'b, 'cfg>(out: &'a mut HashMap<Unit<'b>, BuildScripts>,
                           cx: &Context<'b, 'cfg>,
                           unit: &Unit<'b>)
                           -> &'a BuildScripts {
        // Do a quick pre-flight check to see if we've already calculated the
        // set of dependencies.
        if out.contains_key(unit) {
            return &out[unit]
        }
        let mut to_link = BTreeSet::new();
        let mut plugins = BTreeSet::new();
        if !unit.target.is_custom_build() && unit.pkg.has_custom_build() {
            to_link.insert((unit.pkg.package_id().clone(), unit.kind));
        }
        for unit in cx.dep_targets(unit).iter() {
            let dep_scripts = build(out, cx, unit);
            if unit.target.for_host() {
                plugins.extend(dep_scripts.to_link.iter()
                                          .map(|p| &p.0).cloned());
            } else if unit.target.linkable() {
                to_link.extend(dep_scripts.to_link.iter().cloned());
            }
        }
        let prev = out.entry(*unit).or_insert(BuildScripts::default());
        prev.to_link.extend(to_link);
        prev.plugins.extend(plugins);
        prev
    }
fn build < ' a , ' b , ' cfg > ( out : & ' a mut HashMap < Unit < ' b > , BuildScripts > , cx : & Context < ' b , ' cfg > , unit : & Unit < ' b > ) -> & ' a BuildScripts { // Do a quick pre-flight check to see if we've already calculated the // set of dependencies. if out . contains_key ( unit ) { return & out [ unit ] } let mut to_link = BTreeSet :: new ( ) ; let mut plugins = BTreeSet :: new ( ) ; if ! unit . target . is_custom_build ( ) && unit . pkg . has_custom_build ( ) { to_link . insert ( ( unit . pkg . package_id ( ) . clone ( ) , unit . kind ) ) ; } for unit in cx . dep_targets ( unit ) . iter ( ) { let dep_scripts = build ( out , cx , unit ) ; if unit . target . for_host ( ) { plugins . extend ( dep_scripts . to_link . iter ( ) . map ( | p | & p . 0 ) . cloned ( ) ) ; } else if unit . target . linkable ( ) { to_link . extend ( dep_scripts . to_link . iter ( ) . cloned ( ) ) ; } } let prev = out . entry ( * unit ) . or_insert ( BuildScripts :: default ( ) ) ; prev . to_link . extend ( to_link ) ; prev . plugins . extend ( plugins ) ; prev }
Recursive function to build up the map we're constructing.
Recursive function to build up the map we ' re constructing .
out
&'a mut HashMap<Unit<'b>, BuildScripts>
cx
&Context<'b, 'cfg>
unit
&Unit<'b>
out
&'a mut HashMap<Unit<'b>, BuildScripts>
cx
&Context<'b, 'cfg>
unit
&Unit<'b>