pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>,
                           units: &[Unit<'b>]) {
    let mut ret = HashMap::new();
    for unit in units {
        build(&mut ret, cx, unit);
    }
    cx.build_scripts.extend(ret.into_iter().map(|(k, v)| {
        (k, Arc::new(v))
    }));

    // 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
    }
}
/// Compute the `build_scripts` map in the `Context` which tracks what build
/// scripts each package depends on.
///
/// The global `build_scripts` map lists for all (package, kind) tuples what set
/// of packages' build script outputs must be considered. For example this lists
/// all dependencies' `-L` flags which need to be propagated transitively.
///
/// The given set of targets to this function is the initial set of
/// targets/profiles which are being built.
Compute the `build_scripts` map in the `Context` which tracks what build
scripts each package depends on.

The global `build_scripts` map lists for all (package, kind) tuples what set
of packages' build script outputs must be considered. For example this lists
all dependencies' `-L` flags which need to be propagated transitively.

The given set of targets to this function is the initial set of
targets/profiles which are being built.
Compute the ` build_scripts ` map in the ` Context ` which tracks what build scripts each package depends on . The global ` build_scripts ` map lists for all ( package kind ) tuples what set of packages ' build script outputs must be considered . For example this lists all dependencies ' ` - L ` flags which need to be propagated transitively . The given set of targets to this function is the initial set of targets / profiles which are being built .
pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>,
                           units: &[Unit<'b>]) {
    let mut ret = HashMap::new();
    for unit in units {
        build(&mut ret, cx, unit);
    }
    cx.build_scripts.extend(ret.into_iter().map(|(k, v)| {
        (k, Arc::new(v))
    }));
    // 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
    }
}
pub fn build_map < ' b , ' cfg > ( cx : & mut Context < ' b , ' cfg > , units : & [ Unit < ' b > ] ) { let mut ret = HashMap :: new ( ) ; for unit in units { build ( & mut ret , cx , unit ) ; } cx . build_scripts . extend ( ret . into_iter ( ) . map ( | ( k , v ) | { ( k , Arc :: new ( v ) ) } ) ) ; // 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 } }
Compute the `build_scripts` map in the `Context` which tracks what build
scripts each package depends on.
Compute the ` build_scripts ` map in the ` Context ` which tracks what build scripts each package depends on .
cx
&mut Context<'b, 'cfg>
units
&[Unit<'b>]
cx
&mut Context<'b, 'cfg>
units
&[Unit<'b>]