@@ -181,7 +181,7 @@ pub fn main() !void {
181181 };
182182 } else if (mem .eql (u8 , arg , "--summary" )) {
183183 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 });
185185 summary = std .meta .stringToEnum (Summary , next_arg ) orelse {
186186 fatalWithHint ("expected [all|failures|none] after '{s}', found '{s}'" , .{
187187 arg , next_arg ,
@@ -534,7 +534,8 @@ fn runStepNames(
534534
535535 // A proper command line application defaults to silently succeeding.
536536 // 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 ();
538539
539540 const ttyconf = run .ttyconf ;
540541 const stderr = run .stderr ;
@@ -559,26 +560,31 @@ fn runStepNames(
559560 ttyconf .setColor (stderr , .reset ) catch {};
560561 }
561562 stderr .writeAll ("\n " ) catch {};
562- const failures_only = run .summary != Summary .all ;
563563
564564 // Print a fancy tree with build results.
565565 var print_node : PrintNode = .{ .parent = null };
566566 if (step_names .len == 0 ) {
567567 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 {};
569569 } 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 : {
571571 var i : usize = step_names .len ;
572572 while (i > 0 ) {
573573 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 ;
575581 }
576582 break :blk b .top_level_steps .count ();
577583 };
578584 for (step_names , 0.. ) | step_name , i | {
579585 const tls = b .top_level_steps .get (step_name ).? ;
580586 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 {};
582588 }
583589 }
584590 }
@@ -770,10 +776,16 @@ fn printTreeStep(
770776 ttyconf : std.io.tty.Config ,
771777 parent_node : * PrintNode ,
772778 step_stack : * std .AutoArrayHashMapUnmanaged (* Step , void ),
773- failures_only : bool ,
774779) ! void {
775780 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 ;
777789 try printPrefix (parent_node , stderr , ttyconf );
778790
779791 if (! first ) try ttyconf .setColor (stderr , .dim );
@@ -794,11 +806,18 @@ fn printTreeStep(
794806 if (first ) {
795807 try printStepStatus (s , stderr , ttyconf , run );
796808
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 : {
798810 var i : usize = s .dependencies .items .len ;
799811 while (i > 0 ) {
800812 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 ;
802821 }
803822 break :blk s .dependencies .items .len - | 1 ;
804823 };
@@ -807,7 +826,7 @@ fn printTreeStep(
807826 .parent = parent_node ,
808827 .last = i == last_index ,
809828 };
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 );
811830 }
812831 } else {
813832 if (s .dependencies .items .len == 0 ) {
@@ -1113,6 +1132,7 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
11131132 \\ --prominent-compile-errors Buffer compile errors and display at end
11141133 \\ --summary [mode] Control the printing of the build summary
11151134 \\ all Print the build summary in its entirety
1135+ \\ new Omit cached steps
11161136 \\ failures (Default) Only print failed steps
11171137 \\ none Do not print the build summary
11181138 \\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
@@ -1225,7 +1245,7 @@ fn cleanExit() void {
12251245}
12261246
12271247const Color = enum { auto , off , on };
1228- const Summary = enum { all , failures , none };
1248+ const Summary = enum { all , new , failures , none };
12291249
12301250fn get_tty_conf (color : Color , stderr : File ) std.io.tty.Config {
12311251 return switch (color ) {
0 commit comments