Fix progress when multiple zig rc child processes are building resinator

This commit is contained in:
Ryan Liptak 2024-03-09 17:47:56 -08:00
parent b16890e6dd
commit c32e0d3000
2 changed files with 11 additions and 5 deletions

View File

@ -47,9 +47,9 @@ pub fn main() !void {
}; };
if (zig_integration) { if (zig_integration) {
// Send progress with an empty string to indicate that the building of the // Send progress with a special string to indicate that the building of the
// resinator binary is finished and we've moved on to actually compiling the .rc file // resinator binary is finished and we've moved on to actually compiling the .rc file
try error_handler.server.serveStringMessage(.progress, ""); try error_handler.server.serveStringMessage(.progress, "<resinator>");
} }
var options = options: { var options = options: {

View File

@ -5042,12 +5042,18 @@ fn spawnZigRc(
}, },
.progress => { .progress => {
node_name.clearRetainingCapacity(); node_name.clearRetainingCapacity();
if (body.len > 0) { // <resinator> is a special string that indicates that the child
// process has reached resinator's main function
if (std.mem.eql(u8, body, "<resinator>")) {
child_progress_node.setName(src_basename);
}
// Ignore 0-length strings since if multiple zig rc commands
// are executed at the same time, only one will send progress strings
// while the other(s) will send empty strings.
else if (body.len > 0) {
try node_name.appendSlice(arena, "build 'zig rc'... "); try node_name.appendSlice(arena, "build 'zig rc'... ");
try node_name.appendSlice(arena, body); try node_name.appendSlice(arena, body);
child_progress_node.setName(node_name.items); child_progress_node.setName(node_name.items);
} else {
child_progress_node.setName(src_basename);
} }
}, },
else => {}, // ignore other messages else => {}, // ignore other messages