From 9612be6803423c490b73b9610695884b605ca27f Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 12 Jul 2018 11:59:35 +0800 Subject: [PATCH] Compile progress: Do not update when a build script prints something. Fix #5697. There may still be some little flickering, but should be much less severe than before. --- src/cargo/core/compiler/job_queue.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 5d1afa7f12f..98e0ca0f75e 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -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(); } @@ -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::>(); - 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::>(); + 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) => {