build runner: update watch caption to include subprocesses

This commit is contained in:
Andrew Kelley 2024-07-14 22:27:51 -07:00
parent 987f63208e
commit 445bd7a06f
3 changed files with 12 additions and 5 deletions

View File

@ -72,7 +72,6 @@ pub fn main() !void {
.query = .{},
.result = try std.zig.system.resolveTargetQuery(.{}),
},
.incremental = null,
};
graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() });
@ -411,8 +410,8 @@ pub fn main() !void {
// trigger a rebuild on all steps with modified inputs, as well as their
// recursive dependants.
var caption_buf: [std.Progress.Node.max_name_len]u8 = undefined;
const caption = std.fmt.bufPrint(&caption_buf, "Watching {d} Directories", .{
w.dir_table.entries.len,
const caption = std.fmt.bufPrint(&caption_buf, "watching {d} directories, {d} processes", .{
w.dir_table.entries.len, countSubProcesses(run.step_stack.keys()),
}) catch &caption_buf;
var debouncing_node = main_progress_node.start(caption, 0);
var debounce_timeout: Watch.Timeout = .none;
@ -445,6 +444,14 @@ fn markFailedStepsDirty(gpa: Allocator, all_steps: []const *Step) void {
};
}
fn countSubProcesses(all_steps: []const *Step) usize {
var count: usize = 0;
for (all_steps) |s| {
count += @intFromBool(s.getZigProcess() != null);
}
return count;
}
const Run = struct {
max_rss: u64,
max_rss_is_default: bool,

View File

@ -120,7 +120,7 @@ pub const Graph = struct {
needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .{},
/// Information about the native target. Computed before build() is invoked.
host: ResolvedTarget,
incremental: ?bool,
incremental: ?bool = null,
};
const AvailableDeps = []const struct { []const u8, []const u8 };

View File

@ -603,7 +603,7 @@ fn zigProcessUpdate(s: *Step, zp: *ZigProcess, watch: bool) !?[]const u8 {
return result;
}
fn getZigProcess(s: *Step) ?*ZigProcess {
pub fn getZigProcess(s: *Step) ?*ZigProcess {
return switch (s.id) {
.compile => s.cast(Compile).?.zig_process,
else => null,