From c54a7ca4b25a0ffe080a80fb19986142c98b124e Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Thu, 20 Jan 2022 03:42:27 +0000 Subject: [PATCH] allow `expected_exit_code` to be `null` --- lib/std/build/RunStep.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/std/build/RunStep.zig b/lib/std/build/RunStep.zig index c04ad95d3e..4e18d5d738 100644 --- a/lib/std/build/RunStep.zig +++ b/lib/std/build/RunStep.zig @@ -34,7 +34,8 @@ stderr_action: StdIoAction = .inherit, stdin_behavior: std.ChildProcess.StdIo = .Inherit, -expected_exit_code: u8 = 0, +/// Set this to `null` to ignore the exit code for the purpose of determining a successful execution +expected_exit_code: ?u8 = 0, /// Print the command before running it print: bool, @@ -220,17 +221,19 @@ fn make(step: *Step) !void { }; switch (term) { - .Exited => |code| { - if (code != self.expected_exit_code) { + .Exited => |code| blk: { + const expected_exit_code = self.expected_exit_code orelse break :blk; + + if (code != expected_exit_code) { if (self.builder.prominent_compile_errors) { std.debug.print("Run step exited with error code {} (expected {})\n", .{ code, - self.expected_exit_code, + expected_exit_code, }); } else { std.debug.print("The following command exited with error code {} (expected {}):\n", .{ code, - self.expected_exit_code, + expected_exit_code, }); printCmd(cwd, argv); }