pub compilation: Compilation<'cfg>,
pub packages: &'a PackageSet<'cfg>,
pub build_state: Arc<BuildState>,
+ pub build_script_overridden: HashSet<(PackageId, Kind)>,
pub build_explicit_deps: HashMap<Unit<'a>, BuildDeps>,
pub fingerprints: HashMap<Unit<'a>, Arc<Fingerprint>>,
pub compiled: HashSet<Unit<'a>>,
used_in_plugin: HashSet::new(),
incremental_enabled: incremental_enabled,
jobserver: jobserver,
+ build_script_overridden: HashSet::new(),
// TODO: Pre-Calculate these with a topo-sort, rather than lazy-calculating
target_filenames: HashMap::new(),
self.resolve.features_sorted(unit.pkg.package_id()).hash(&mut hasher);
// Mix in the target-metadata of all the dependencies of this target
- if let Ok(deps) = self.used_deps(unit) {
+ if let Ok(deps) = self.dep_targets(unit) {
let mut deps_metadata = deps.into_iter().map(|dep_unit| {
self.target_metadata(&dep_unit)
}).collect::<Vec<_>>();
Ok(Arc::new(ret))
}
- fn used_deps(&self, unit: &Unit<'a>) -> CargoResult<Vec<Unit<'a>>> {
+ /// For a package, return all targets which are registered as dependencies
+ /// for that package.
+ pub fn dep_targets(&self, unit: &Unit<'a>) -> CargoResult<Vec<Unit<'a>>> {
+ if unit.profile.run_custom_build {
+ return self.dep_run_custom_build(unit)
+ } else if unit.profile.doc && !unit.profile.test {
+ return self.doc_deps(unit);
+ }
+
let id = unit.pkg.package_id();
let deps = self.resolve.deps(id);
- deps.filter(|dep| {
+ let mut ret = deps.filter(|dep| {
unit.pkg.dependencies().iter().filter(|d| {
d.name() == dep.name() && d.version_req().matches(dep.version())
}).any(|d| {
}
Err(e) => Some(Err(e))
}
- }).collect::<CargoResult<Vec<_>>>()
- }
-
- /// For a package, return all targets which are registered as dependencies
- /// for that package.
- pub fn dep_targets(&self, unit: &Unit<'a>) -> CargoResult<Vec<Unit<'a>>> {
- if unit.profile.run_custom_build {
- return self.dep_run_custom_build(unit)
- } else if unit.profile.doc && !unit.profile.test {
- return self.doc_deps(unit);
- }
-
- let id = unit.pkg.package_id();
- let mut ret = self.used_deps(unit)?;
+ }).collect::<CargoResult<Vec<_>>>()?;
// If this target is a build script, then what we've collected so far is
// all we need. If this isn't a build script, then it depends on the
// actually depend on anything, we've reached the end of the dependency
// chain as we've got all the info we're gonna get.
let key = (unit.pkg.package_id().clone(), unit.kind);
- if self.build_state.outputs.lock().unwrap().contains_key(&key) {
+ if self.build_script_overridden.contains(&key) {
return Ok(Vec::new())
}
-> CargoResult<(Work, Work, Freshness)> {
let _p = profile::start(format!("build script prepare: {}/{}",
unit.pkg, unit.target.name()));
- let overridden = cx.build_state.has_override(unit);
+
+ let key = (unit.pkg.package_id().clone(), unit.kind);
+ let overridden = cx.build_script_overridden.contains(&key);
let (work_dirty, work_fresh) = if overridden {
(Work::noop(), Work::noop())
} else {
fn insert(&self, id: PackageId, kind: Kind, output: BuildOutput) {
self.outputs.lock().unwrap().insert((id, kind), output);
}
-
- fn has_override(&self, unit: &Unit) -> bool {
- let key = unit.pkg.manifest().links().map(|l| (l.to_string(), unit.kind));
- match key.and_then(|k| self.overrides.get(&k)) {
- Some(output) => {
- self.insert(unit.pkg.package_id().clone(), unit.kind,
- output.clone());
- true
- }
- None => false,
- }
- }
}
impl BuildOutput {
// 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>,
+ cx: &mut Context<'b, 'cfg>,
unit: &Unit<'b>)
-> CargoResult<&'a BuildScripts> {
// Do a quick pre-flight check to see if we've already calculated the
return Ok(&out[unit])
}
+ {
+ let key = unit.pkg.manifest().links().map(|l| (l.to_string(), unit.kind));
+ let build_state = &cx.build_state;
+ if let Some(output) = key.and_then(|k| build_state.overrides.get(&k)) {
+ let key = (unit.pkg.package_id().clone(), unit.kind);
+ cx.build_script_overridden.insert(key.clone());
+ build_state
+ .outputs
+ .lock()
+ .unwrap()
+ .insert(key, output.clone());
+ }
+ }
+
let mut ret = BuildScripts::default();
if !unit.target.is_custom_build() && unit.pkg.has_custom_build() {