| ... | ... | @@ -278,8 +278,12 @@ pub fn main() !void { |
| 278 | 278 | .windows_api => {}, |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | | var progress: std.Progress = .{ .dont_print_on_dumb = true }; |
| 281 | var progress: std.Progress = .{}; |
| 282 | 282 | const main_progress_node = progress.start("", 0); |
| 283 | if (ttyconf == .no_color) { |
| 284 | progress.timer = null; |
| 285 | progress.terminal = null; |
| 286 | } |
| 283 | 287 | |
| 284 | 288 | builder.debug_log_scopes = debug_log_scopes.items; |
| 285 | 289 | builder.resolveInstallPrefix(install_prefix, dir_list); |
| ... | ... | @@ -302,6 +306,9 @@ pub fn main() !void { |
| 302 | 306 | .enable_summary = enable_summary, |
| 303 | 307 | .ttyconf = ttyconf, |
| 304 | 308 | .stderr = stderr, |
| 309 | |
| 310 | .step_index = 0, |
| 311 | .step_count = undefined, |
| 305 | 312 | }; |
| 306 | 313 | |
| 307 | 314 | if (run.max_rss == 0) { |
| ... | ... | @@ -332,6 +339,9 @@ const Run = struct { |
| 332 | 339 | enable_summary: ?bool, |
| 333 | 340 | ttyconf: std.debug.TTY.Config, |
| 334 | 341 | stderr: std.fs.File, |
| 342 | |
| 343 | step_count: usize, |
| 344 | step_index: usize, |
| 335 | 345 | }; |
| 336 | 346 | |
| 337 | 347 | fn runStepNames( |
| ... | ... | @@ -395,7 +405,8 @@ fn runStepNames( |
| 395 | 405 | { |
| 396 | 406 | defer parent_prog_node.end(); |
| 397 | 407 | |
| 398 | | var step_prog = parent_prog_node.start("run steps", step_stack.count()); |
| 408 | run.step_count = step_stack.count(); |
| 409 | var step_prog = parent_prog_node.start("run steps", run.step_count); |
| 399 | 410 | defer step_prog.end(); |
| 400 | 411 | |
| 401 | 412 | var wait_group: std.Thread.WaitGroup = .{}; |
| ... | ... | @@ -739,10 +750,27 @@ fn workerMakeOneStep( |
| 739 | 750 | sub_prog_node.activate(); |
| 740 | 751 | defer sub_prog_node.end(); |
| 741 | 752 | |
| 742 | | // I suspect we will want to pass `b` to make() in a future modification. |
| 743 | | // For example, CompileStep does some sus things with modifying the saved |
| 744 | | // *Build object in install header steps that might be able to be removed |
| 745 | | // by passing the *Build object through the make() functions. |
| 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 | |
| 746 | 774 | const make_result = s.make(&sub_prog_node); |
| 747 | 775 | |
| 748 | 776 | // No matter the result, we want to display error/warning messages. |
| ... | ... | @@ -750,9 +778,6 @@ fn workerMakeOneStep( |
| 750 | 778 | sub_prog_node.context.lock_stderr(); |
| 751 | 779 | defer sub_prog_node.context.unlock_stderr(); |
| 752 | 780 | |
| 753 | | const stderr = run.stderr; |
| 754 | | const ttyconf = run.ttyconf; |
| 755 | | |
| 756 | 781 | for (s.result_error_msgs.items) |msg| { |
| 757 | 782 | // Sometimes it feels like you just can't catch a break. Finally, |
| 758 | 783 | // with Zig, you can. |