authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-14 21:38:55-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-14 21:38:55-07:00
logf6c1b71c220406d60ca4bdf9c949e775f7fca466
treea7984a9aeb0639c6ad604e3c954f7b3b7db99af5
parentf33395ce6a66df517c09037c4a4f1756ef7f6f2e

build system: update std.Progress.Node for long-lived children


1 files changed, 5 insertions(+), 0 deletions(-)

lib/std/Build/Step.zig+5
...@@ -361,6 +361,7 @@ pub fn addError(step: *Step, comptime fmt: []const u8, args: anytype) error{OutO...@@ -361,6 +361,7 @@ pub fn addError(step: *Step, comptime fmt: []const u8, args: anytype) error{OutO
361pub const ZigProcess = struct {361pub const ZigProcess = struct {
362 child: std.process.Child,362 child: std.process.Child,
363 poller: std.io.Poller(StreamEnum),363 poller: std.io.Poller(StreamEnum),
364 progress_ipc_fd: if (std.Progress.have_ipc) ?std.posix.fd_t else void,
364365
365 pub const StreamEnum = enum { stdout, stderr };366 pub const StreamEnum = enum { stdout, stderr };
366};367};
...@@ -375,6 +376,7 @@ pub fn evalZigProcess(...@@ -375,6 +376,7 @@ pub fn evalZigProcess(
375) !?[]const u8 {376) !?[]const u8 {
376 if (s.getZigProcess()) |zp| {377 if (s.getZigProcess()) |zp| {
377 assert(watch);378 assert(watch);
379 if (std.Progress.have_ipc) if (zp.progress_ipc_fd) |fd| prog_node.setIpcFd(fd);
378 return zigProcessUpdate(s, zp, watch);380 return zigProcessUpdate(s, zp, watch);
379 }381 }
380 assert(argv.len != 0);382 assert(argv.len != 0);
...@@ -404,6 +406,7 @@ pub fn evalZigProcess(...@@ -404,6 +406,7 @@ pub fn evalZigProcess(
404 .stdout = child.stdout.?,406 .stdout = child.stdout.?,
405 .stderr = child.stderr.?,407 .stderr = child.stderr.?,
406 }),408 }),
409 .progress_ipc_fd = if (std.Progress.have_ipc) child.progress_node.getIpcFd() else {},
407 };410 };
408 if (watch) s.setZigProcess(zp);411 if (watch) s.setZigProcess(zp);
409 defer if (!watch) zp.poller.deinit();412 defer if (!watch) zp.poller.deinit();
...@@ -435,6 +438,8 @@ pub fn evalZigProcess(...@@ -435,6 +438,8 @@ pub fn evalZigProcess(
435 try handleChildProcessTerm(s, term, null, argv);438 try handleChildProcessTerm(s, term, null, argv);
436 }439 }
437440
441 // This is intentionally printed for failure on the first build but not for
442 // subsequent rebuilds.
438 if (s.result_error_bundle.errorMessageCount() > 0) {443 if (s.result_error_bundle.errorMessageCount() > 0) {
439 return s.fail("the following command failed with {d} compilation errors:\n{s}", .{444 return s.fail("the following command failed with {d} compilation errors:\n{s}", .{
440 s.result_error_bundle.errorMessageCount(),445 s.result_error_bundle.errorMessageCount(),