| ... | ... | @@ -350,6 +350,8 @@ fn runStepNames( |
| 350 | 350 | var failure_count: usize = 0; |
| 351 | 351 | var pending_count: usize = 0; |
| 352 | 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 | 356 | for (step_stack.keys()) |s| { |
| 355 | 357 | switch (s.state) { |
| ... | ... | @@ -369,7 +371,11 @@ fn runStepNames( |
| 369 | 371 | .success => success_count += 1, |
| 370 | 372 | .failure => { |
| 371 | 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 | 398 | var print_node: PrintNode = .{ .parent = null }; |
| 393 | 399 | if (step_names.len == 0) { |
| 394 | 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 | 402 | } else { |
| 397 | 403 | for (step_names, 0..) |step_name, i| { |
| 398 | 404 | const tls = b.top_level_steps.get(step_name).?; |
| 399 | 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 | 410 | if (failure_count == 0) return cleanExit(); |
| 405 | 411 | |
| 406 | 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 | 415 | if (total_compile_errors > 0) { |
| 408 | | for (step_stack.keys()) |s| { |
| 416 | for (compile_error_steps.items) |s| { |
| 409 | 417 | if (s.result_error_bundle.errorMessageCount() > 0) { |
| 410 | 418 | s.result_error_bundle.renderToStdErr(ttyconf); |
| 411 | 419 | } |
| ... | ... | @@ -442,7 +450,10 @@ fn printTreeStep( |
| 442 | 450 | stderr: std.fs.File, |
| 443 | 451 | ttyconf: std.debug.TTY.Config, |
| 444 | 452 | parent_node: *PrintNode, |
| 453 | step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void), |
| 445 | 454 | ) !void { |
| 455 | const first = step_stack.swapRemove(s); |
| 456 | if (!first) try ttyconf.setColor(stderr, .Dim); |
| 446 | 457 | try printPrefix(parent_node, stderr); |
| 447 | 458 | |
| 448 | 459 | if (parent_node.parent != null) { |
| ... | ... | @@ -456,43 +467,48 @@ fn printTreeStep( |
| 456 | 467 | // TODO print the dep prefix too? |
| 457 | 468 | try stderr.writeAll(s.name); |
| 458 | 469 | |
| 459 | | switch (s.state) { |
| 460 | | .precheck_unstarted => unreachable, |
| 461 | | .precheck_started => unreachable, |
| 462 | | .precheck_done => unreachable, |
| 463 | | .running => unreachable, |
| 470 | if (first) { |
| 471 | switch (s.state) { |
| 472 | .precheck_unstarted => unreachable, |
| 473 | .precheck_started => unreachable, |
| 474 | .precheck_done => unreachable, |
| 475 | .running => unreachable, |
| 464 | 476 | |
| 465 | | .dependency_failure => { |
| 466 | | try ttyconf.setColor(stderr, .Dim); |
| 467 | | try stderr.writeAll(" transitive failure\n"); |
| 468 | | try ttyconf.setColor(stderr, .Reset); |
| 469 | | }, |
| 477 | .dependency_failure => { |
| 478 | try ttyconf.setColor(stderr, .Dim); |
| 479 | try stderr.writeAll(" transitive failure\n"); |
| 480 | try ttyconf.setColor(stderr, .Reset); |
| 481 | }, |
| 470 | 482 | |
| 471 | | .success => { |
| 472 | | try ttyconf.setColor(stderr, .Green); |
| 473 | | try stderr.writeAll(" success\n"); |
| 474 | | try ttyconf.setColor(stderr, .Reset); |
| 475 | | }, |
| 483 | .success => { |
| 484 | try ttyconf.setColor(stderr, .Green); |
| 485 | try stderr.writeAll(" success\n"); |
| 486 | try ttyconf.setColor(stderr, .Reset); |
| 487 | }, |
| 476 | 488 | |
| 477 | | .failure => { |
| 478 | | try ttyconf.setColor(stderr, .Red); |
| 479 | | if (s.result_error_bundle.errorMessageCount() > 0) { |
| 480 | | try stderr.writer().print(" {d} errors\n", .{ |
| 481 | | s.result_error_bundle.errorMessageCount(), |
| 482 | | }); |
| 483 | | } else { |
| 484 | | try stderr.writeAll(" failure\n"); |
| 485 | | } |
| 486 | | try ttyconf.setColor(stderr, .Reset); |
| 487 | | }, |
| 488 | | } |
| 489 | .failure => { |
| 490 | try ttyconf.setColor(stderr, .Red); |
| 491 | if (s.result_error_bundle.errorMessageCount() > 0) { |
| 492 | try stderr.writer().print(" {d} errors\n", .{ |
| 493 | s.result_error_bundle.errorMessageCount(), |
| 494 | }); |
| 495 | } else { |
| 496 | try stderr.writeAll(" failure\n"); |
| 497 | } |
| 498 | try ttyconf.setColor(stderr, .Reset); |
| 499 | }, |
| 500 | } |
| 489 | 501 | |
| 490 | | for (s.dependencies.items, 0..) |dep, i| { |
| 491 | | var print_node: PrintNode = .{ |
| 492 | | .parent = parent_node, |
| 493 | | .last = i == s.dependencies.items.len - 1, |
| 494 | | }; |
| 495 | | try printTreeStep(b, dep, stderr, ttyconf, &print_node); |
| 502 | for (s.dependencies.items, 0..) |dep, i| { |
| 503 | var print_node: PrintNode = .{ |
| 504 | .parent = parent_node, |
| 505 | .last = i == s.dependencies.items.len - 1, |
| 506 | }; |
| 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 | |