| ... | ... | @@ -74,6 +74,7 @@ pub fn main() !void { |
| 74 | 74 | .query = .{}, |
| 75 | 75 | .result = try std.zig.system.resolveTargetQuery(.{}), |
| 76 | 76 | }, |
| 77 | .watch = null, |
| 77 | 78 | }; |
| 78 | 79 | |
| 79 | 80 | graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); |
| ... | ... | @@ -97,12 +98,12 @@ pub fn main() !void { |
| 97 | 98 | var dir_list = std.Build.DirList{}; |
| 98 | 99 | var summary: ?Summary = null; |
| 99 | 100 | var max_rss: u64 = 0; |
| 100 | | var skip_oom_steps: bool = false; |
| 101 | var skip_oom_steps = false; |
| 101 | 102 | var color: Color = .auto; |
| 102 | 103 | var seed: u32 = 0; |
| 103 | | var prominent_compile_errors: bool = false; |
| 104 | | var help_menu: bool = false; |
| 105 | | var steps_menu: bool = false; |
| 104 | var prominent_compile_errors = false; |
| 105 | var help_menu = false; |
| 106 | var steps_menu = false; |
| 106 | 107 | var output_tmp_nonce: ?[16]u8 = null; |
| 107 | 108 | |
| 108 | 109 | while (nextArg(args, &arg_idx)) |arg| { |
| ... | ... | @@ -227,6 +228,10 @@ pub fn main() !void { |
| 227 | 228 | builder.verbose_llvm_cpu_features = true; |
| 228 | 229 | } else if (mem.eql(u8, arg, "--prominent-compile-errors")) { |
| 229 | 230 | prominent_compile_errors = true; |
| 231 | } else if (mem.eql(u8, arg, "--watch")) { |
| 232 | const watch = try arena.create(std.Build.Watch); |
| 233 | watch.* = std.Build.Watch.init; |
| 234 | graph.watch = watch; |
| 230 | 235 | } else if (mem.eql(u8, arg, "-fwine")) { |
| 231 | 236 | builder.enable_wine = true; |
| 232 | 237 | } else if (mem.eql(u8, arg, "-fno-wine")) { |
| ... | ... | @@ -344,7 +349,7 @@ pub fn main() !void { |
| 344 | 349 | .prominent_compile_errors = prominent_compile_errors, |
| 345 | 350 | |
| 346 | 351 | .claimed_rss = 0, |
| 347 | | .summary = summary, |
| 352 | .summary = summary orelse if (graph.watch != null) .new else .failures, |
| 348 | 353 | .ttyconf = ttyconf, |
| 349 | 354 | .stderr = stderr, |
| 350 | 355 | }; |
| ... | ... | @@ -363,7 +368,10 @@ pub fn main() !void { |
| 363 | 368 | &run, |
| 364 | 369 | seed, |
| 365 | 370 | ) catch |err| switch (err) { |
| 366 | | error.UncleanExit => process.exit(1), |
| 371 | error.UncleanExit => { |
| 372 | if (graph.watch == null) |
| 373 | process.exit(1); |
| 374 | }, |
| 367 | 375 | else => return err, |
| 368 | 376 | }; |
| 369 | 377 | } |
| ... | ... | @@ -377,7 +385,7 @@ const Run = struct { |
| 377 | 385 | prominent_compile_errors: bool, |
| 378 | 386 | |
| 379 | 387 | claimed_rss: usize, |
| 380 | | summary: ?Summary, |
| 388 | summary: Summary, |
| 381 | 389 | ttyconf: std.io.tty.Config, |
| 382 | 390 | stderr: File, |
| 383 | 391 | }; |
| ... | ... | @@ -417,7 +425,7 @@ fn runStepNames( |
| 417 | 425 | |
| 418 | 426 | for (starting_steps) |s| { |
| 419 | 427 | constructGraphAndCheckForDependencyLoop(b, s, &step_stack, rand) catch |err| switch (err) { |
| 420 | | error.DependencyLoopDetected => return error.UncleanExit, |
| 428 | error.DependencyLoopDetected => return uncleanExit(), |
| 421 | 429 | else => |e| return e, |
| 422 | 430 | }; |
| 423 | 431 | } |
| ... | ... | @@ -442,7 +450,7 @@ fn runStepNames( |
| 442 | 450 | if (run.max_rss_is_default) { |
| 443 | 451 | std.debug.print("note: use --maxrss to override the default", .{}); |
| 444 | 452 | } |
| 445 | | return error.UncleanExit; |
| 453 | return uncleanExit(); |
| 446 | 454 | } |
| 447 | 455 | } |
| 448 | 456 | |
| ... | ... | @@ -524,13 +532,19 @@ fn runStepNames( |
| 524 | 532 | |
| 525 | 533 | // A proper command line application defaults to silently succeeding. |
| 526 | 534 | // The user may request verbose mode if they have a different preference. |
| 527 | | const failures_only = run.summary != .all and run.summary != .new; |
| 528 | | if (failure_count == 0 and failures_only) return cleanExit(); |
| 535 | const failures_only = switch (run.summary) { |
| 536 | .failures, .none => true, |
| 537 | else => false, |
| 538 | }; |
| 539 | if (failure_count == 0 and failures_only) { |
| 540 | if (b.graph.watch != null) return; |
| 541 | return cleanExit(); |
| 542 | } |
| 529 | 543 | |
| 530 | 544 | const ttyconf = run.ttyconf; |
| 531 | 545 | const stderr = run.stderr; |
| 532 | 546 | |
| 533 | | if (run.summary != Summary.none) { |
| 547 | if (run.summary != .none) { |
| 534 | 548 | const total_count = success_count + failure_count + pending_count + skipped_count; |
| 535 | 549 | ttyconf.setColor(stderr, .cyan) catch {}; |
| 536 | 550 | stderr.writeAll("Build Summary:") catch {}; |
| ... | ... | @@ -544,11 +558,6 @@ fn runStepNames( |
| 544 | 558 | if (test_fail_count > 0) stderr.writer().print("; {d} failed", .{test_fail_count}) catch {}; |
| 545 | 559 | if (test_leak_count > 0) stderr.writer().print("; {d} leaked", .{test_leak_count}) catch {}; |
| 546 | 560 | |
| 547 | | if (run.summary == null) { |
| 548 | | ttyconf.setColor(stderr, .dim) catch {}; |
| 549 | | stderr.writeAll(" (disable with --summary none)") catch {}; |
| 550 | | ttyconf.setColor(stderr, .reset) catch {}; |
| 551 | | } |
| 552 | 561 | stderr.writeAll("\n") catch {}; |
| 553 | 562 | |
| 554 | 563 | // Print a fancy tree with build results. |
| ... | ... | @@ -562,7 +571,7 @@ fn runStepNames( |
| 562 | 571 | while (i > 0) { |
| 563 | 572 | i -= 1; |
| 564 | 573 | const step = b.top_level_steps.get(step_names[i]).?.step; |
| 565 | | const found = switch (run.summary orelse .failures) { |
| 574 | const found = switch (run.summary) { |
| 566 | 575 | .all, .none => unreachable, |
| 567 | 576 | .failures => step.state != .success, |
| 568 | 577 | .new => !step.result_cached, |
| ... | ... | @@ -579,7 +588,10 @@ fn runStepNames( |
| 579 | 588 | } |
| 580 | 589 | } |
| 581 | 590 | |
| 582 | | if (failure_count == 0) return cleanExit(); |
| 591 | if (failure_count == 0) { |
| 592 | if (b.graph.watch != null) return; |
| 593 | return cleanExit(); |
| 594 | } |
| 583 | 595 | |
| 584 | 596 | // Finally, render compile errors at the bottom of the terminal. |
| 585 | 597 | // We use a separate compile_error_steps array list because step_stack is destructively |
| ... | ... | @@ -591,13 +603,24 @@ fn runStepNames( |
| 591 | 603 | } |
| 592 | 604 | } |
| 593 | 605 | |
| 606 | if (b.graph.watch != null) return uncleanExit(); |
| 607 | |
| 594 | 608 | // Signal to parent process that we have printed compile errors. The |
| 595 | 609 | // parent process may choose to omit the "following command failed" |
| 596 | 610 | // line in this case. |
| 597 | 611 | process.exit(2); |
| 598 | 612 | } |
| 599 | 613 | |
| 600 | | process.exit(1); |
| 614 | return uncleanExit(); |
| 615 | } |
| 616 | |
| 617 | fn uncleanExit() error{UncleanExit}!void { |
| 618 | if (builtin.mode == .Debug) { |
| 619 | return error.UncleanExit; |
| 620 | } else { |
| 621 | std.debug.lockStdErr(); |
| 622 | process.exit(1); |
| 623 | } |
| 601 | 624 | } |
| 602 | 625 | |
| 603 | 626 | const PrintNode = struct { |
| ... | ... | @@ -768,7 +791,7 @@ fn printTreeStep( |
| 768 | 791 | step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void), |
| 769 | 792 | ) !void { |
| 770 | 793 | const first = step_stack.swapRemove(s); |
| 771 | | const summary = run.summary orelse .failures; |
| 794 | const summary = run.summary; |
| 772 | 795 | const skip = switch (summary) { |
| 773 | 796 | .none => unreachable, |
| 774 | 797 | .all => false, |
| ... | ... | @@ -1124,6 +1147,7 @@ fn usage(b: *std.Build, out_stream: anytype) !void { |
| 1124 | 1147 | \\ --maxrss <bytes> Limit memory usage (default is to use available memory) |
| 1125 | 1148 | \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss |
| 1126 | 1149 | \\ --fetch Exit after fetching dependency tree |
| 1150 | \\ --watch Continuously rebuild when source files are modified |
| 1127 | 1151 | \\ |
| 1128 | 1152 | \\Project-Specific Options: |
| 1129 | 1153 | \\ |