pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>,
                                unit: &Unit<'a>) -> CargoResult<Preparation> {
    let _p = profile::start(format!("fingerprint: {} / {}",
                                    unit.pkg.package_id(), unit.target.name()));
    let new = dir(cx, unit);
    let loc = new.join(&filename(unit));

    debug!("fingerprint at: {}", loc.display());

    let fingerprint = try!(calculate(cx, unit));
    let compare = compare_old_fingerprint(&loc, &*fingerprint);
    log_compare(unit, &compare);

    let root = cx.out_dir(unit);
    let mut missing_outputs = false;
    if !unit.profile.doc {
        for filename in try!(cx.target_filenames(unit)).iter() {
            missing_outputs |= fs::metadata(root.join(filename)).is_err();
        }
    }

    let allow_failure = unit.profile.rustc_args.is_some();
    let write_fingerprint = Work::new(move |_| {
        match fingerprint.update_local() {
            Ok(()) => {}
            Err(..) if allow_failure => return Ok(()),
            Err(e) => return Err(e)
        }
        write_fingerprint(&loc, &*fingerprint)
    });

    let fresh = compare.is_ok() && !missing_outputs;
    Ok((if fresh {Fresh} else {Dirty}, write_fingerprint, Work::noop()))
}
/// Prepare the necessary work for the fingerprint for a specific target.
///
/// When dealing with fingerprints, cargo gets to choose what granularity
/// "freshness" is considered at. One option is considering freshness at the
/// package level. This means that if anything in a package changes, the entire
/// package is rebuilt, unconditionally. This simplicity comes at a cost,
/// however, in that test-only changes will cause libraries to be rebuilt, which
/// is quite unfortunate!
///
/// The cost was deemed high enough that fingerprints are now calculated at the
/// layer of a target rather than a package. Each target can then be kept track
/// of separately and only rebuilt as necessary. This requires cargo to
/// understand what the inputs are to a target, so we drive rustc with the
/// --dep-info flag to learn about all input files to a unit of compilation.
///
/// This function will calculate the fingerprint for a target and prepare the
/// work necessary to either write the fingerprint or copy over all fresh files
/// from the old directories to their new locations.
Prepare the necessary work for the fingerprint for a specific target.
When dealing with fingerprints, cargo gets to choose what granularity
"freshness" is considered at. One option is considering freshness at the
package level. This means that if anything in a package changes, the entire
package is rebuilt, unconditionally. This simplicity comes at a cost,
however, in that test-only changes will cause libraries to be rebuilt, which
is quite unfortunate!

The cost was deemed high enough that fingerprints are now calculated at the
layer of a target rather than a package. Each target can then be kept track
of separately and only rebuilt as necessary. This requires cargo to
understand what the inputs are to a target, so we drive rustc with the
dep-info flag to learn about all input files to a unit of compilation.

This function will calculate the fingerprint for a target and prepare the
work necessary to either write the fingerprint or copy over all fresh files
from the old directories to their new locations.
Prepare the necessary work for the fingerprint for a specific target . When dealing with fingerprints cargo gets to choose what granularity " freshness " is considered at . One option is considering freshness at the package level . This means that if anything in a package changes the entire package is rebuilt unconditionally . This simplicity comes at a cost however in that test - only changes will cause libraries to be rebuilt which is quite unfortunate! The cost was deemed high enough that fingerprints are now calculated at the layer of a target rather than a package . Each target can then be kept track of separately and only rebuilt as necessary . This requires cargo to understand what the inputs are to a target so we drive rustc with the dep - info flag to learn about all input files to a unit of compilation . This function will calculate the fingerprint for a target and prepare the work necessary to either write the fingerprint or copy over all fresh files from the old directories to their new locations .
pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>,
                                unit: &Unit<'a>) -> CargoResult<Preparation> {
    let _p = profile::start(format!("fingerprint: {} / {}",
                                    unit.pkg.package_id(), unit.target.name()));
    let new = dir(cx, unit);
    let loc = new.join(&filename(unit));
    debug!("fingerprint at: {}", loc.display());
    let fingerprint = try!(calculate(cx, unit));
    let compare = compare_old_fingerprint(&loc, &*fingerprint);
    log_compare(unit, &compare);
    let root = cx.out_dir(unit);
    let mut missing_outputs = false;
    if !unit.profile.doc {
        for filename in try!(cx.target_filenames(unit)).iter() {
            missing_outputs |= fs::metadata(root.join(filename)).is_err();
        }
    }
    let allow_failure = unit.profile.rustc_args.is_some();
    let write_fingerprint = Work::new(move |_| {
        match fingerprint.update_local() {
            Ok(()) => {}
            Err(..) if allow_failure => return Ok(()),
            Err(e) => return Err(e)
        }
        write_fingerprint(&loc, &*fingerprint)
    });
    let fresh = compare.is_ok() && !missing_outputs;
    Ok((if fresh {Fresh} else {Dirty}, write_fingerprint, Work::noop()))
}
pub fn prepare_target < ' a , ' cfg > ( cx : & mut Context < ' a , ' cfg > , unit : & Unit < ' a > ) -> CargoResult < Preparation > { let _p = profile :: start ( format ! ( " " unit pkg package_id ( ) unit target name ( ) ) ) ; let new = dir ( cx , unit ) ; let loc = new . join ( & filename ( unit ) ) ; debug ! ( " " loc display ( ) ) ; let fingerprint = try ! ( calculate ( cx unit ) ) ; let compare = compare_old_fingerprint ( & loc , & * fingerprint ) ; log_compare ( unit , & compare ) ; let root = cx . out_dir ( unit ) ; let mut missing_outputs = false ; if ! unit . profile . doc { for filename in try ! ( cx target_filenames ( unit ) ) . iter ( ) { missing_outputs |= fs :: metadata ( root . join ( filename ) ) . is_err ( ) ; } } let allow_failure = unit . profile . rustc_args . is_some ( ) ; let write_fingerprint = Work :: new ( move | _ | { match fingerprint . update_local ( ) { Ok ( ( ) ) => { } Err ( .. ) if allow_failure => return Ok ( ( ) ) , Err ( e ) => return Err ( e ) } write_fingerprint ( & loc , & * fingerprint ) } ) ; let fresh = compare . is_ok ( ) && ! missing_outputs ; Ok ( ( if fresh { Fresh } else { Dirty } , write_fingerprint , Work :: noop ( ) ) ) }
Prepare the necessary work for the fingerprint for a specific target.
Prepare the necessary work for the fingerprint for a specific target .
cx
&mut Context<'a, 'cfg>
unit
&Unit<'a>
cx
&mut Context<'a, 'cfg>
unit
&Unit<'a>