| ... | @@ -437,7 +437,7 @@ pub fn buildOutputType( | ... | @@ -437,7 +437,7 @@ pub fn buildOutputType( |
| 437 | if (mem.startsWith(u8, arg, "-")) { | 437 | if (mem.startsWith(u8, arg, "-")) { |
| 438 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 438 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 439 | try io.getStdOut().writeAll(usage_build_generic); | 439 | try io.getStdOut().writeAll(usage_build_generic); |
| 440 | return process.cleanExit(); | 440 | return cleanExit(); |
| 441 | } else if (mem.eql(u8, arg, "--")) { | 441 | } else if (mem.eql(u8, arg, "--")) { |
| 442 | if (arg_mode == .run) { | 442 | if (arg_mode == .run) { |
| 443 | runtime_args_start = i + 1; | 443 | runtime_args_start = i + 1; |
| ... | @@ -1506,7 +1506,7 @@ pub fn buildOutputType( | ... | @@ -1506,7 +1506,7 @@ pub fn buildOutputType( |
| 1506 | else => process.exit(1), | 1506 | else => process.exit(1), |
| 1507 | } | 1507 | } |
| 1508 | if (!watch) | 1508 | if (!watch) |
| 1509 | return process.cleanExit(); | 1509 | return cleanExit(); |
| 1510 | }, | 1510 | }, |
| 1511 | else => {}, | 1511 | else => {}, |
| 1512 | } | 1512 | } |
| ... | @@ -1667,7 +1667,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -1667,7 +1667,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { |
| 1667 | if (mem.eql(u8, arg, "--help")) { | 1667 | if (mem.eql(u8, arg, "--help")) { |
| 1668 | const stdout = io.getStdOut().writer(); | 1668 | const stdout = io.getStdOut().writer(); |
| 1669 | try stdout.writeAll(usage_libc); | 1669 | try stdout.writeAll(usage_libc); |
| 1670 | return process.cleanExit(); | 1670 | return cleanExit(); |
| 1671 | } else { | 1671 | } else { |
| 1672 | fatal("unrecognized parameter: '{}'", .{arg}); | 1672 | fatal("unrecognized parameter: '{}'", .{arg}); |
| 1673 | } | 1673 | } |
| ... | @@ -1724,7 +1724,7 @@ pub fn cmdInit( | ... | @@ -1724,7 +1724,7 @@ pub fn cmdInit( |
| 1724 | if (mem.startsWith(u8, arg, "-")) { | 1724 | if (mem.startsWith(u8, arg, "-")) { |
| 1725 | if (mem.eql(u8, arg, "--help")) { | 1725 | if (mem.eql(u8, arg, "--help")) { |
| 1726 | try io.getStdOut().writeAll(usage_init); | 1726 | try io.getStdOut().writeAll(usage_init); |
| 1727 | return process.cleanExit(); | 1727 | return cleanExit(); |
| 1728 | } else { | 1728 | } else { |
| 1729 | fatal("unrecognized parameter: '{}'", .{arg}); | 1729 | fatal("unrecognized parameter: '{}'", .{arg}); |
| 1730 | } | 1730 | } |
| ... | @@ -2012,7 +2012,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v | ... | @@ -2012,7 +2012,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2012 | const term = try child.spawnAndWait(); | 2012 | const term = try child.spawnAndWait(); |
| 2013 | switch (term) { | 2013 | switch (term) { |
| 2014 | .Exited => |code| { | 2014 | .Exited => |code| { |
| 2015 | if (code == 0) return process.cleanExit(); | 2015 | if (code == 0) return cleanExit(); |
| 2016 | try cmd.writer().print("failed with exit code {}:\n", .{code}); | 2016 | try cmd.writer().print("failed with exit code {}:\n", .{code}); |
| 2017 | }, | 2017 | }, |
| 2018 | else => { | 2018 | else => { |
| ... | @@ -2073,7 +2073,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2073,7 +2073,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2073 | if (mem.eql(u8, arg, "--help")) { | 2073 | if (mem.eql(u8, arg, "--help")) { |
| 2074 | const stdout = io.getStdOut().outStream(); | 2074 | const stdout = io.getStdOut().outStream(); |
| 2075 | try stdout.writeAll(usage_fmt); | 2075 | try stdout.writeAll(usage_fmt); |
| 2076 | return process.cleanExit(); | 2076 | return cleanExit(); |
| 2077 | } else if (mem.eql(u8, arg, "--color")) { | 2077 | } else if (mem.eql(u8, arg, "--color")) { |
| 2078 | if (i + 1 >= args.len) { | 2078 | if (i + 1 >= args.len) { |
| 2079 | fatal("expected [auto|on|off] after --color", .{}); | 2079 | fatal("expected [auto|on|off] after --color", .{}); |
| ... | @@ -2804,3 +2804,16 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s | ... | @@ -2804,3 +2804,16 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s |
| 2804 | } | 2804 | } |
| 2805 | return info; | 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 | } |