Skip to content

Commit 9612be6

Browse files
committed
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.
1 parent 6ce9087 commit 9612be6

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,10 @@ impl<'a> JobQueue<'a> {
190190
// bar we'll need to probably capture the stderr of rustc and
191191
// capture compiler error messages, but that also means
192192
// reproducing rustc's styling of error messages which is
193-
// currently a pretty big task. This is issue #5695. Note that
194-
// when reenabling it'd also probably be good to fix #5697 while
195-
// we're at it.
193+
// currently a pretty big task. This is issue #5695.
196194
let mut error = None;
197195
let mut progress = Progress::with_style("Building", ProgressStyle::Ratio, cx.bcx.config);
196+
let mut progress_maybe_changed = true; // avoid flickering due to build script
198197
if !cx.bcx.config.cli_unstable().compile_progress {
199198
progress.disable();
200199
}
@@ -242,14 +241,23 @@ impl<'a> JobQueue<'a> {
242241
// to the jobserver itself.
243242
tokens.truncate(self.active.len() - 1);
244243

245-
let count = total - self.queue.len();
246-
let active_names = self.active.iter().map(|key| match key.mode {
247-
CompileMode::Doc { .. } => format!("{}(doc)", key.pkg.name()),
248-
_ => key.pkg.name().to_string(),
249-
}).collect::<Vec<_>>();
250-
drop(progress.tick_now(count, total, &format!(": {}", active_names.join(", "))));
244+
if progress_maybe_changed {
245+
let count = total - self.queue.len();
246+
let active_names = self.active.iter().map(|key| match key.mode {
247+
CompileMode::Doc { .. } => format!("{}(doc)", key.pkg.name()),
248+
_ => key.pkg.name().to_string(),
249+
}).collect::<Vec<_>>();
250+
drop(progress.tick_now(count, total, &format!(": {}", active_names.join(", "))));
251+
}
251252
let event = self.rx.recv().unwrap();
252-
progress.clear();
253+
254+
progress_maybe_changed = match event {
255+
Message::Stdout(_) | Message::Stderr(_) => cx.bcx.config.extra_verbose(),
256+
_ => true,
257+
};
258+
if progress_maybe_changed {
259+
progress.clear();
260+
}
253261

254262
match event {
255263
Message::Run(cmd) => {

0 commit comments

Comments
 (0)