Skip to content

Commit

Permalink
Auto merge of #4266 - nrc:force, r=alexcrichton
Browse files Browse the repository at this point in the history
Add a way to force a unit of work to always be rebuilt
  • Loading branch information
bors committed Jul 10, 2017
2 parents 9e664bd + c7b2df1 commit 04d8a13
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ pub trait Executor: Send + Sync + 'static {
cmd.exec_with_streaming(handle_stdout, handle_stderr, false)?;
Ok(())
}

/// Queried when queuing each unit of work. If it returns true, then the
/// unit will always be rebuilt, independent of whether it needs to be.
fn force_rebuild(&self, _unit: &Unit) -> bool {
false
}
}

/// A DefaultExecutor calls rustc without doing anything else. It is Cargo's
Expand Down Expand Up @@ -230,7 +236,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>,
// we run these targets later, so this is just a noop for now
(Work::new(|_| Ok(())), Work::new(|_| Ok(())), Freshness::Fresh)
} else {
let (freshness, dirty, fresh) = fingerprint::prepare_target(cx, unit)?;
let (mut freshness, dirty, fresh) = fingerprint::prepare_target(cx, unit)?;
let work = if unit.profile.doc {
rustdoc(cx, unit)?
} else {
Expand All @@ -239,6 +245,11 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>,
// Need to link targets on both the dirty and fresh
let dirty = work.then(link_targets(cx, unit, false)?).then(dirty);
let fresh = link_targets(cx, unit, true)?.then(fresh);

if exec.force_rebuild(unit) {
freshness = Freshness::Dirty;
}

(dirty, fresh, freshness)
};
jobs.enqueue(cx, unit, Job::new(dirty, fresh), freshness)?;
Expand Down

0 comments on commit 04d8a13

Please sign in to comment.