Skip to content

Commit

Permalink
Compile progress: Do not update when a build script prints something.
Browse files Browse the repository at this point in the history
Fix rust-lang#5697. There may still be some little flickering, but should be much
less severe than before.
  • Loading branch information
kennytm committed Jul 12, 2018
1 parent 6ce9087 commit 9612be6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,10 @@ impl<'a> JobQueue<'a> {
// bar we'll need to probably capture the stderr of rustc and
// capture compiler error messages, but that also means
// reproducing rustc's styling of error messages which is
// currently a pretty big task. This is issue #5695. Note that
// when reenabling it'd also probably be good to fix #5697 while
// we're at it.
// currently a pretty big task. This is issue #5695.
let mut error = None;
let mut progress = Progress::with_style("Building", ProgressStyle::Ratio, cx.bcx.config);
let mut progress_maybe_changed = true; // avoid flickering due to build script
if !cx.bcx.config.cli_unstable().compile_progress {
progress.disable();
}
Expand Down Expand Up @@ -242,14 +241,23 @@ impl<'a> JobQueue<'a> {
// to the jobserver itself.
tokens.truncate(self.active.len() - 1);

let count = total - self.queue.len();
let active_names = self.active.iter().map(|key| match key.mode {
CompileMode::Doc { .. } => format!("{}(doc)", key.pkg.name()),
_ => key.pkg.name().to_string(),
}).collect::<Vec<_>>();
drop(progress.tick_now(count, total, &format!(": {}", active_names.join(", "))));
if progress_maybe_changed {
let count = total - self.queue.len();
let active_names = self.active.iter().map(|key| match key.mode {
CompileMode::Doc { .. } => format!("{}(doc)", key.pkg.name()),
_ => key.pkg.name().to_string(),
}).collect::<Vec<_>>();
drop(progress.tick_now(count, total, &format!(": {}", active_names.join(", "))));
}
let event = self.rx.recv().unwrap();
progress.clear();

progress_maybe_changed = match event {
Message::Stdout(_) | Message::Stderr(_) => cx.bcx.config.extra_verbose(),
_ => true,
};
if progress_maybe_changed {
progress.clear();
}

match event {
Message::Run(cmd) => {
Expand Down

0 comments on commit 9612be6

Please sign in to comment.