Skip to content

Commit

Permalink
build system: update std.Progress.Node for long-lived children
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jul 15, 2024
1 parent f33395c commit f6c1b71
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/std/Build/Step.zig
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ pub fn addError(step: *Step, comptime fmt: []const u8, args: anytype) error{OutO
pub const ZigProcess = struct {
child: std.process.Child,
poller: std.io.Poller(StreamEnum),
progress_ipc_fd: if (std.Progress.have_ipc) ?std.posix.fd_t else void,

pub const StreamEnum = enum { stdout, stderr };
};
Expand All @@ -375,6 +376,7 @@ pub fn evalZigProcess(
) !?[]const u8 {
if (s.getZigProcess()) |zp| {
assert(watch);
if (std.Progress.have_ipc) if (zp.progress_ipc_fd) |fd| prog_node.setIpcFd(fd);
return zigProcessUpdate(s, zp, watch);
}
assert(argv.len != 0);
Expand Down Expand Up @@ -404,6 +406,7 @@ pub fn evalZigProcess(
.stdout = child.stdout.?,
.stderr = child.stderr.?,
}),
.progress_ipc_fd = if (std.Progress.have_ipc) child.progress_node.getIpcFd() else {},
};
if (watch) s.setZigProcess(zp);
defer if (!watch) zp.poller.deinit();
Expand Down Expand Up @@ -435,6 +438,8 @@ pub fn evalZigProcess(
try handleChildProcessTerm(s, term, null, argv);
}

// This is intentionally printed for failure on the first build but not for
// subsequent rebuilds.
if (s.result_error_bundle.errorMessageCount() > 0) {
return s.fail("the following command failed with {d} compilation errors:\n{s}", .{
s.result_error_bundle.errorMessageCount(),
Expand Down

0 comments on commit f6c1b71

Please sign in to comment.