Commit 445bd7a06f

Andrew Kelley <andrew@ziglang.org>
2024-07-15 07:27:51
build runner: update watch caption to include subprocesses
1 parent 987f632
Changed files (3)
lib
lib/compiler/build_runner.zig
@@ -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,
lib/std/Build/Step.zig
@@ -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,
lib/std/Build.zig
@@ -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 };