| ... | @@ -350,6 +350,8 @@ fn runStepNames( | ... | @@ -350,6 +350,8 @@ fn runStepNames( |
| 350 | var failure_count: usize = 0; | 350 | var failure_count: usize = 0; |
| 351 | var pending_count: usize = 0; | 351 | var pending_count: usize = 0; |
| 352 | var total_compile_errors: usize = 0; | 352 | var total_compile_errors: usize = 0; |
| | 353 | var compile_error_steps: std.ArrayListUnmanaged(*Step) = .{}; |
| | 354 | defer compile_error_steps.deinit(gpa); |
| 353 | | 355 | |
| 354 | for (step_stack.keys()) |s| { | 356 | for (step_stack.keys()) |s| { |
| 355 | switch (s.state) { | 357 | switch (s.state) { |
| ... | @@ -369,7 +371,11 @@ fn runStepNames( | ... | @@ -369,7 +371,11 @@ fn runStepNames( |
| 369 | .success => success_count += 1, | 371 | .success => success_count += 1, |
| 370 | .failure => { | 372 | .failure => { |
| 371 | failure_count += 1; | 373 | failure_count += 1; |
| 372 | total_compile_errors += s.result_error_bundle.errorMessageCount(); | 374 | const compile_errors_len = s.result_error_bundle.errorMessageCount(); |
| | 375 | if (compile_errors_len > 0) { |
| | 376 | total_compile_errors += compile_errors_len; |
| | 377 | try compile_error_steps.append(gpa, s); |
| | 378 | } |
| 373 | }, | 379 | }, |
| 374 | } | 380 | } |
| 375 | } | 381 | } |
| ... | @@ -392,20 +398,22 @@ fn runStepNames( | ... | @@ -392,20 +398,22 @@ fn runStepNames( |
| 392 | var print_node: PrintNode = .{ .parent = null }; | 398 | var print_node: PrintNode = .{ .parent = null }; |
| 393 | if (step_names.len == 0) { | 399 | if (step_names.len == 0) { |
| 394 | print_node.last = true; | 400 | print_node.last = true; |
| 395 | printTreeStep(b, b.default_step, stderr, ttyconf, &print_node) catch {}; | 401 | printTreeStep(b, b.default_step, stderr, ttyconf, &print_node, &step_stack) catch {}; |
| 396 | } else { | 402 | } else { |
| 397 | for (step_names, 0..) |step_name, i| { | 403 | for (step_names, 0..) |step_name, i| { |
| 398 | const tls = b.top_level_steps.get(step_name).?; | 404 | const tls = b.top_level_steps.get(step_name).?; |
| 399 | print_node.last = i + 1 == b.top_level_steps.count(); | 405 | print_node.last = i + 1 == b.top_level_steps.count(); |
| 400 | printTreeStep(b, &tls.step, stderr, ttyconf, &print_node) catch {}; | 406 | printTreeStep(b, &tls.step, stderr, ttyconf, &print_node, &step_stack) catch {}; |
| 401 | } | 407 | } |
| 402 | } | 408 | } |
| 403 | | 409 | |
| 404 | if (failure_count == 0) return cleanExit(); | 410 | if (failure_count == 0) return cleanExit(); |
| 405 | | 411 | |
| 406 | // Finally, render compile errors at the bottom of the terminal. | 412 | // Finally, render compile errors at the bottom of the terminal. |
| | 413 | // We use a separate compile_error_steps array list because step_stack is destructively |
| | 414 | // mutated in printTreeStep above. |
| 407 | if (total_compile_errors > 0) { | 415 | if (total_compile_errors > 0) { |
| 408 | for (step_stack.keys()) |s| { | 416 | for (compile_error_steps.items) |s| { |
| 409 | if (s.result_error_bundle.errorMessageCount() > 0) { | 417 | if (s.result_error_bundle.errorMessageCount() > 0) { |
| 410 | s.result_error_bundle.renderToStdErr(ttyconf); | 418 | s.result_error_bundle.renderToStdErr(ttyconf); |
| 411 | } | 419 | } |
| ... | @@ -442,7 +450,10 @@ fn printTreeStep( | ... | @@ -442,7 +450,10 @@ fn printTreeStep( |
| 442 | stderr: std.fs.File, | 450 | stderr: std.fs.File, |
| 443 | ttyconf: std.debug.TTY.Config, | 451 | ttyconf: std.debug.TTY.Config, |
| 444 | parent_node: *PrintNode, | 452 | parent_node: *PrintNode, |
| | 453 | step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void), |
| 445 | ) !void { | 454 | ) !void { |
| | 455 | const first = step_stack.swapRemove(s); |
| | 456 | if (!first) try ttyconf.setColor(stderr, .Dim); |
| 446 | try printPrefix(parent_node, stderr); | 457 | try printPrefix(parent_node, stderr); |
| 447 | | 458 | |
| 448 | if (parent_node.parent != null) { | 459 | if (parent_node.parent != null) { |
| ... | @@ -456,43 +467,48 @@ fn printTreeStep( | ... | @@ -456,43 +467,48 @@ fn printTreeStep( |
| 456 | // TODO print the dep prefix too? | 467 | // TODO print the dep prefix too? |
| 457 | try stderr.writeAll(s.name); | 468 | try stderr.writeAll(s.name); |
| 458 | | 469 | |
| 459 | switch (s.state) { | 470 | if (first) { |
| 460 | .precheck_unstarted => unreachable, | 471 | switch (s.state) { |
| 461 | .precheck_started => unreachable, | 472 | .precheck_unstarted => unreachable, |
| 462 | .precheck_done => unreachable, | 473 | .precheck_started => unreachable, |
| 463 | .running => unreachable, | 474 | .precheck_done => unreachable, |
| | 475 | .running => unreachable, |
| 464 | | 476 | |
| 465 | .dependency_failure => { | 477 | .dependency_failure => { |
| 466 | try ttyconf.setColor(stderr, .Dim); | 478 | try ttyconf.setColor(stderr, .Dim); |
| 467 | try stderr.writeAll(" transitive failure\n"); | 479 | try stderr.writeAll(" transitive failure\n"); |
| 468 | try ttyconf.setColor(stderr, .Reset); | 480 | try ttyconf.setColor(stderr, .Reset); |
| 469 | }, | 481 | }, |
| 470 | | 482 | |
| 471 | .success => { | 483 | .success => { |
| 472 | try ttyconf.setColor(stderr, .Green); | 484 | try ttyconf.setColor(stderr, .Green); |
| 473 | try stderr.writeAll(" success\n"); | 485 | try stderr.writeAll(" success\n"); |
| 474 | try ttyconf.setColor(stderr, .Reset); | 486 | try ttyconf.setColor(stderr, .Reset); |
| 475 | }, | 487 | }, |
| 476 | | 488 | |
| 477 | .failure => { | 489 | .failure => { |
| 478 | try ttyconf.setColor(stderr, .Red); | 490 | try ttyconf.setColor(stderr, .Red); |
| 479 | if (s.result_error_bundle.errorMessageCount() > 0) { | 491 | if (s.result_error_bundle.errorMessageCount() > 0) { |
| 480 | try stderr.writer().print(" {d} errors\n", .{ | 492 | try stderr.writer().print(" {d} errors\n", .{ |
| 481 | s.result_error_bundle.errorMessageCount(), | 493 | s.result_error_bundle.errorMessageCount(), |
| 482 | }); | 494 | }); |
| 483 | } else { | 495 | } else { |
| 484 | try stderr.writeAll(" failure\n"); | 496 | try stderr.writeAll(" failure\n"); |
| 485 | } | 497 | } |
| 486 | try ttyconf.setColor(stderr, .Reset); | 498 | try ttyconf.setColor(stderr, .Reset); |
| 487 | }, | 499 | }, |
| 488 | } | 500 | } |
| 489 | | 501 | |
| 490 | for (s.dependencies.items, 0..) |dep, i| { | 502 | for (s.dependencies.items, 0..) |dep, i| { |
| 491 | var print_node: PrintNode = .{ | 503 | var print_node: PrintNode = .{ |
| 492 | .parent = parent_node, | 504 | .parent = parent_node, |
| 493 | .last = i == s.dependencies.items.len - 1, | 505 | .last = i == s.dependencies.items.len - 1, |
| 494 | }; | 506 | }; |
| 495 | try printTreeStep(b, dep, stderr, ttyconf, &print_node); | 507 | try printTreeStep(b, dep, stderr, ttyconf, &print_node, step_stack); |
| | 508 | } |
| | 509 | } else { |
| | 510 | try stderr.writer().print(" ({d} repeated dependencies)\n", .{s.dependencies.items.len}); |
| | 511 | try ttyconf.setColor(stderr, .Reset); |
| 496 | } | 512 | } |
| 497 | } | 513 | } |
| 498 | | 514 | |