| ... | ... | @@ -181,7 +181,7 @@ pub fn main() !void { |
| 181 | 181 | }; |
| 182 | 182 | } else if (mem.eql(u8, arg, "--summary")) { |
| 183 | 183 | const next_arg = nextArg(args, &arg_idx) orelse |
| 184 | | fatalWithHint("expected [all|failures|none] after '{s}'", .{arg}); |
| 184 | fatalWithHint("expected [all|new|failures|none] after '{s}'", .{arg}); |
| 185 | 185 | summary = std.meta.stringToEnum(Summary, next_arg) orelse { |
| 186 | 186 | fatalWithHint("expected [all|failures|none] after '{s}', found '{s}'", .{ |
| 187 | 187 | arg, next_arg, |
| ... | ... | @@ -534,7 +534,8 @@ fn runStepNames( |
| 534 | 534 | |
| 535 | 535 | // A proper command line application defaults to silently succeeding. |
| 536 | 536 | // The user may request verbose mode if they have a different preference. |
| 537 | | if (failure_count == 0 and run.summary != Summary.all) return cleanExit(); |
| 537 | const failures_only = run.summary != .all and run.summary != .new; |
| 538 | if (failure_count == 0 and failures_only) return cleanExit(); |
| 538 | 539 | |
| 539 | 540 | const ttyconf = run.ttyconf; |
| 540 | 541 | const stderr = run.stderr; |
| ... | ... | @@ -559,26 +560,31 @@ fn runStepNames( |
| 559 | 560 | ttyconf.setColor(stderr, .reset) catch {}; |
| 560 | 561 | } |
| 561 | 562 | stderr.writeAll("\n") catch {}; |
| 562 | | const failures_only = run.summary != Summary.all; |
| 563 | 563 | |
| 564 | 564 | // Print a fancy tree with build results. |
| 565 | 565 | var print_node: PrintNode = .{ .parent = null }; |
| 566 | 566 | if (step_names.len == 0) { |
| 567 | 567 | print_node.last = true; |
| 568 | | printTreeStep(b, b.default_step, run, stderr, ttyconf, &print_node, &step_stack, failures_only) catch {}; |
| 568 | printTreeStep(b, b.default_step, run, stderr, ttyconf, &print_node, &step_stack) catch {}; |
| 569 | 569 | } else { |
| 570 | | const last_index = if (!failures_only) b.top_level_steps.count() else blk: { |
| 570 | const last_index = if (run.summary == .all) b.top_level_steps.count() else blk: { |
| 571 | 571 | var i: usize = step_names.len; |
| 572 | 572 | while (i > 0) { |
| 573 | 573 | i -= 1; |
| 574 | | if (b.top_level_steps.get(step_names[i]).?.step.state != .success) break :blk i; |
| 574 | const step = b.top_level_steps.get(step_names[i]).?.step; |
| 575 | const found = switch (run.summary orelse .failures) { |
| 576 | .all, .none => unreachable, |
| 577 | .failures => step.state != .success, |
| 578 | .new => !step.result_cached, |
| 579 | }; |
| 580 | if (found) break :blk i; |
| 575 | 581 | } |
| 576 | 582 | break :blk b.top_level_steps.count(); |
| 577 | 583 | }; |
| 578 | 584 | for (step_names, 0..) |step_name, i| { |
| 579 | 585 | const tls = b.top_level_steps.get(step_name).?; |
| 580 | 586 | print_node.last = i + 1 == last_index; |
| 581 | | printTreeStep(b, &tls.step, run, stderr, ttyconf, &print_node, &step_stack, failures_only) catch {}; |
| 587 | printTreeStep(b, &tls.step, run, stderr, ttyconf, &print_node, &step_stack) catch {}; |
| 582 | 588 | } |
| 583 | 589 | } |
| 584 | 590 | } |
| ... | ... | @@ -770,10 +776,16 @@ fn printTreeStep( |
| 770 | 776 | ttyconf: std.io.tty.Config, |
| 771 | 777 | parent_node: *PrintNode, |
| 772 | 778 | step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void), |
| 773 | | failures_only: bool, |
| 774 | 779 | ) !void { |
| 775 | 780 | const first = step_stack.swapRemove(s); |
| 776 | | if (failures_only and s.state == .success) return; |
| 781 | const summary = run.summary orelse .failures; |
| 782 | const skip = switch (summary) { |
| 783 | .none => unreachable, |
| 784 | .all => false, |
| 785 | .new => s.result_cached, |
| 786 | .failures => s.state == .success, |
| 787 | }; |
| 788 | if (skip) return; |
| 777 | 789 | try printPrefix(parent_node, stderr, ttyconf); |
| 778 | 790 | |
| 779 | 791 | if (!first) try ttyconf.setColor(stderr, .dim); |
| ... | ... | @@ -794,11 +806,18 @@ fn printTreeStep( |
| 794 | 806 | if (first) { |
| 795 | 807 | try printStepStatus(s, stderr, ttyconf, run); |
| 796 | 808 | |
| 797 | | const last_index = if (!failures_only) s.dependencies.items.len -| 1 else blk: { |
| 809 | const last_index = if (summary == .all) s.dependencies.items.len -| 1 else blk: { |
| 798 | 810 | var i: usize = s.dependencies.items.len; |
| 799 | 811 | while (i > 0) { |
| 800 | 812 | i -= 1; |
| 801 | | if (s.dependencies.items[i].state != .success) break :blk i; |
| 813 | |
| 814 | const step = s.dependencies.items[i]; |
| 815 | const found = switch (summary) { |
| 816 | .all, .none => unreachable, |
| 817 | .failures => step.state != .success, |
| 818 | .new => !step.result_cached, |
| 819 | }; |
| 820 | if (found) break :blk i; |
| 802 | 821 | } |
| 803 | 822 | break :blk s.dependencies.items.len -| 1; |
| 804 | 823 | }; |
| ... | ... | @@ -807,7 +826,7 @@ fn printTreeStep( |
| 807 | 826 | .parent = parent_node, |
| 808 | 827 | .last = i == last_index, |
| 809 | 828 | }; |
| 810 | | try printTreeStep(b, dep, run, stderr, ttyconf, &print_node, step_stack, failures_only); |
| 829 | try printTreeStep(b, dep, run, stderr, ttyconf, &print_node, step_stack); |
| 811 | 830 | } |
| 812 | 831 | } else { |
| 813 | 832 | if (s.dependencies.items.len == 0) { |
| ... | ... | @@ -1113,6 +1132,7 @@ fn usage(b: *std.Build, out_stream: anytype) !void { |
| 1113 | 1132 | \\ --prominent-compile-errors Buffer compile errors and display at end |
| 1114 | 1133 | \\ --summary [mode] Control the printing of the build summary |
| 1115 | 1134 | \\ all Print the build summary in its entirety |
| 1135 | \\ new Omit cached steps |
| 1116 | 1136 | \\ failures (Default) Only print failed steps |
| 1117 | 1137 | \\ none Do not print the build summary |
| 1118 | 1138 | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) |
| ... | ... | @@ -1225,7 +1245,7 @@ fn cleanExit() void { |
| 1225 | 1245 | } |
| 1226 | 1246 | |
| 1227 | 1247 | const Color = enum { auto, off, on }; |
| 1228 | | const Summary = enum { all, failures, none }; |
| 1248 | const Summary = enum { all, new, failures, none }; |
| 1229 | 1249 | |
| 1230 | 1250 | fn get_tty_conf(color: Color, stderr: File) std.io.tty.Config { |
| 1231 | 1251 | return switch (color) { |