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,...@@ -48,6 +48,11 @@ condition: enum { output_outdated, always } = .output_outdated,
48/// that the RunStep should be re-executed.48/// that the RunStep should be re-executed.
49extra_file_dependencies: []const []const u8 = &.{},49extra_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
51pub const StdIoAction = union(enum) {56pub const StdIoAction = union(enum) {
52 inherit,57 inherit,
53 ignore,58 ignore,
...@@ -80,6 +85,7 @@ pub fn create(builder: *std.Build, name: []const u8) *RunStep {...@@ -80,6 +85,7 @@ pub fn create(builder: *std.Build, name: []const u8) *RunStep {
80 .cwd = null,85 .cwd = null,
81 .env_map = null,86 .env_map = null,
82 .print = builder.verbose,87 .print = builder.verbose,
88 .rename_step_with_output_arg = true,
83 };89 };
84 return self;90 return self;
85}91}
...@@ -100,6 +106,11 @@ pub fn addOutputFileArg(rs: *RunStep, basename: []const u8) std.Build.FileSource...@@ -100,6 +106,11 @@ pub fn addOutputFileArg(rs: *RunStep, basename: []const u8) std.Build.FileSource
100 .basename = rs.builder.dupe(basename),106 .basename = rs.builder.dupe(basename),
101 } }) catch @panic("OOM");107 } }) 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
103 return .{ .generated = generated_file };114 return .{ .generated = generated_file };
104}115}
105116
...@@ -207,7 +218,11 @@ fn needOutputCheck(self: RunStep) bool {...@@ -207,7 +218,11 @@ fn needOutputCheck(self: RunStep) bool {
207}218}
208219
209fn make(step: *Step, prog_node: *std.Progress.Node) !void {220fn 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.
210 _ = prog_node;224 _ = prog_node;
225
211 const self = @fieldParentPtr(RunStep, "step", step);226 const self = @fieldParentPtr(RunStep, "step", step);
212 const need_output_check = self.needOutputCheck();227 const need_output_check = self.needOutputCheck();
213228