authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-10 01:02:31-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:14-07:00
logba7795913704028f53de44f836b81437afb5e33e
treef534afdb462a887cacedba70c1e3b93edc1ae452
parent20b35332fec73956c97087959dbc0fa2f78e5553

Revert "build runner: print to stderr in dumb terminals"

This reverts commit e6f759e1c64668c50d3ff2d02c64a66c871da0ac. I changed my mind. I don't like the output because it makes it harder to find the actual errors in CI logs.

1 files changed, 5 insertions(+), 34 deletions(-)

lib/build_runner.zig+5-34
......@@ -278,12 +278,8 @@ pub fn main() !void {
278278 .windows_api => {},
279279 }
280280
281 var progress: std.Progress = .{};
281 var progress: std.Progress = .{ .dont_print_on_dumb = true };
282282 const main_progress_node = progress.start("", 0);
283 if (ttyconf == .no_color) {
284 progress.timer = null;
285 progress.terminal = null;
286 }
287283
288284 builder.debug_log_scopes = debug_log_scopes.items;
289285 builder.resolveInstallPrefix(install_prefix, dir_list);
......@@ -306,9 +302,6 @@ pub fn main() !void {
306302 .enable_summary = enable_summary,
307303 .ttyconf = ttyconf,
308304 .stderr = stderr,
309
310 .step_index = 0,
311 .step_count = undefined,
312305 };
313306
314307 if (run.max_rss == 0) {
......@@ -339,9 +332,6 @@ const Run = struct {
339332 enable_summary: ?bool,
340333 ttyconf: std.debug.TTY.Config,
341334 stderr: std.fs.File,
342
343 step_count: usize,
344 step_index: usize,
345335};
346336
347337fn runStepNames(
......@@ -405,8 +395,7 @@ fn runStepNames(
405395 {
406396 defer parent_prog_node.end();
407397
408 run.step_count = step_stack.count();
409 var step_prog = parent_prog_node.start("run steps", run.step_count);
398 var step_prog = parent_prog_node.start("run steps", step_stack.count());
410399 defer step_prog.end();
411400
412401 var wait_group: std.Thread.WaitGroup = .{};
......@@ -750,27 +739,6 @@ fn workerMakeOneStep(
750739 sub_prog_node.activate();
751740 defer sub_prog_node.end();
752741
753 const stderr = run.stderr;
754 const ttyconf = run.ttyconf;
755
756 // If we are unable to print a fancy terminal progress bar, then we resort
757 // to 1 line printed to stderr for each step, similar to Ninja.
758 if (ttyconf == .no_color) {
759 var buf: [120]u8 = undefined;
760 const step_index = @atomicRmw(usize, &run.step_index, .Add, 1, .Monotonic);
761 const text = std.fmt.bufPrint(&buf, "[{d}/{d}] Making {s}{s}\n", .{
762 step_index + 1, run.step_count, s.owner.dep_prefix, s.name,
763 }) catch |err| switch (err) {
764 error.NoSpaceLeft => blk: {
765 buf[buf.len - 4 ..].* = "...\n".*;
766 break :blk &buf;
767 },
768 };
769 std.debug.getStderrMutex().lock();
770 defer std.debug.getStderrMutex().unlock();
771 stderr.writeAll(text) catch {};
772 }
773
774742 const make_result = s.make(&sub_prog_node);
775743
776744 // No matter the result, we want to display error/warning messages.
......@@ -778,6 +746,9 @@ fn workerMakeOneStep(
778746 sub_prog_node.context.lock_stderr();
779747 defer sub_prog_node.context.unlock_stderr();
780748
749 const stderr = run.stderr;
750 const ttyconf = run.ttyconf;
751
781752 for (s.result_error_msgs.items) |msg| {
782753 // Sometimes it feels like you just can't catch a break. Finally,
783754 // with Zig, you can.