authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-01 14:34:40-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
logb4997d08902ed312d7504765014c34f4ea862534
treeb17a473b8de3a2db8e34f0d9f481b9bc802cb740
parent8c250828a2dbcf2428e06fbc9b2d34b17f42ed66

std.Build.RunStep: better default step name

Now it renames itself when an output argument is added.

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

lib/std/Build/RunStep.zig+15
......@@ -48,6 +48,11 @@ condition: enum { output_outdated, always } = .output_outdated,
4848/// that the RunStep should be re-executed.
4949extra_file_dependencies: []const []const u8 = &.{},
5050
51/// After adding an output argument, this step will by default rename itself
52/// for a better display name in the build summary.
53/// This can be disabled by setting this to false.
54rename_step_with_output_arg: bool,
55
5156pub const StdIoAction = union(enum) {
5257 inherit,
5358 ignore,
......@@ -80,6 +85,7 @@ pub fn create(builder: *std.Build, name: []const u8) *RunStep {
8085 .cwd = null,
8186 .env_map = null,
8287 .print = builder.verbose,
88 .rename_step_with_output_arg = true,
8389 };
8490 return self;
8591}
......@@ -100,6 +106,11 @@ pub fn addOutputFileArg(rs: *RunStep, basename: []const u8) std.Build.FileSource
100106 .basename = rs.builder.dupe(basename),
101107 } }) catch @panic("OOM");
102108
109 if (rs.rename_step_with_output_arg) {
110 rs.rename_step_with_output_arg = false;
111 rs.step.name = rs.builder.fmt("{s} ({s})", .{ rs.step.name, basename });
112 }
113
103114 return .{ .generated = generated_file };
104115}
105116
......@@ -207,7 +218,11 @@ fn needOutputCheck(self: RunStep) bool {
207218}
208219
209220fn make(step: *Step, prog_node: *std.Progress.Node) !void {
221 // Unfortunately we have no way to collect progress from arbitrary programs.
222 // Perhaps in the future Zig could offer some kind of opt-in IPC mechanism that
223 // processes could use to supply progress updates.
210224 _ = prog_node;
225
211226 const self = @fieldParentPtr(RunStep, "step", step);
212227 const need_output_check = self.needOutputCheck();
213228