| ... | ... | @@ -437,7 +437,7 @@ pub fn buildOutputType( |
| 437 | 437 | if (mem.startsWith(u8, arg, "-")) { |
| 438 | 438 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 439 | 439 | try io.getStdOut().writeAll(usage_build_generic); |
| 440 | | return process.cleanExit(); |
| 440 | return cleanExit(); |
| 441 | 441 | } else if (mem.eql(u8, arg, "--")) { |
| 442 | 442 | if (arg_mode == .run) { |
| 443 | 443 | runtime_args_start = i + 1; |
| ... | ... | @@ -1506,7 +1506,7 @@ pub fn buildOutputType( |
| 1506 | 1506 | else => process.exit(1), |
| 1507 | 1507 | } |
| 1508 | 1508 | if (!watch) |
| 1509 | | return process.cleanExit(); |
| 1509 | return cleanExit(); |
| 1510 | 1510 | }, |
| 1511 | 1511 | else => {}, |
| 1512 | 1512 | } |
| ... | ... | @@ -1667,7 +1667,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { |
| 1667 | 1667 | if (mem.eql(u8, arg, "--help")) { |
| 1668 | 1668 | const stdout = io.getStdOut().writer(); |
| 1669 | 1669 | try stdout.writeAll(usage_libc); |
| 1670 | | return process.cleanExit(); |
| 1670 | return cleanExit(); |
| 1671 | 1671 | } else { |
| 1672 | 1672 | fatal("unrecognized parameter: '{}'", .{arg}); |
| 1673 | 1673 | } |
| ... | ... | @@ -1724,7 +1724,7 @@ pub fn cmdInit( |
| 1724 | 1724 | if (mem.startsWith(u8, arg, "-")) { |
| 1725 | 1725 | if (mem.eql(u8, arg, "--help")) { |
| 1726 | 1726 | try io.getStdOut().writeAll(usage_init); |
| 1727 | | return process.cleanExit(); |
| 1727 | return cleanExit(); |
| 1728 | 1728 | } else { |
| 1729 | 1729 | fatal("unrecognized parameter: '{}'", .{arg}); |
| 1730 | 1730 | } |
| ... | ... | @@ -2012,7 +2012,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2012 | 2012 | const term = try child.spawnAndWait(); |
| 2013 | 2013 | switch (term) { |
| 2014 | 2014 | .Exited => |code| { |
| 2015 | | if (code == 0) return process.cleanExit(); |
| 2015 | if (code == 0) return cleanExit(); |
| 2016 | 2016 | try cmd.writer().print("failed with exit code {}:\n", .{code}); |
| 2017 | 2017 | }, |
| 2018 | 2018 | else => { |
| ... | ... | @@ -2073,7 +2073,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2073 | 2073 | if (mem.eql(u8, arg, "--help")) { |
| 2074 | 2074 | const stdout = io.getStdOut().outStream(); |
| 2075 | 2075 | try stdout.writeAll(usage_fmt); |
| 2076 | | return process.cleanExit(); |
| 2076 | return cleanExit(); |
| 2077 | 2077 | } else if (mem.eql(u8, arg, "--color")) { |
| 2078 | 2078 | if (i + 1 >= args.len) { |
| 2079 | 2079 | fatal("expected [auto|on|off] after --color", .{}); |
| ... | ... | @@ -2804,3 +2804,16 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s |
| 2804 | 2804 | } |
| 2805 | 2805 | return info; |
| 2806 | 2806 | } |
| 2807 | |
| 2808 | /// Indicate that we are now terminating with a successful exit code. |
| 2809 | /// In debug builds, this is a no-op, so that the calling code's |
| 2810 | /// cleanup mechanisms are tested and so that external tools that |
| 2811 | /// check for resource leaks can be accurate. In release builds, this |
| 2812 | /// calls exit(0), and does not return. |
| 2813 | pub fn cleanExit() void { |
| 2814 | if (std.builtin.mode == .Debug) { |
| 2815 | return; |
| 2816 | } else { |
| 2817 | process.exit(0); |
| 2818 | } |
| 2819 | } |