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