authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2021-10-29 14:03:00-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-16 16:35:12-05:00
log9c1c1d478d3f5a541c142bb32b22a77c2f500953
treef09e3aa311001df49dede4ea576134dc8265a8c5
parentdcd88ae568a1e9c0315b39801c9ca124e0e9aefc

add print field to RunStep

A new print field is added to RunStep that will control whether it prints the cmd before running it. By default it will be set to builder.verbose which means it will print only if builder.verbose is true.

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

lib/std/build/RunStep.zig+7
...@@ -37,6 +37,9 @@ stdin_behavior: std.ChildProcess.StdIo = .Inherit,...@@ -37,6 +37,9 @@ stdin_behavior: std.ChildProcess.StdIo = .Inherit,
3737
38expected_exit_code: u8 = 0,38expected_exit_code: u8 = 0,
3939
40/// Print the command before running it
41print: bool,
42
40pub const StdIoAction = union(enum) {43pub const StdIoAction = union(enum) {
41 inherit,44 inherit,
42 ignore,45 ignore,
...@@ -58,6 +61,7 @@ pub fn create(builder: *Builder, name: []const u8) *RunStep {...@@ -58,6 +61,7 @@ pub fn create(builder: *Builder, name: []const u8) *RunStep {
58 .argv = ArrayList(Arg).init(builder.allocator),61 .argv = ArrayList(Arg).init(builder.allocator),
59 .cwd = null,62 .cwd = null,
60 .env_map = null,63 .env_map = null,
64 .print = builder.verbose,
61 };65 };
62 return self;66 return self;
63}67}
...@@ -181,6 +185,9 @@ fn make(step: *Step) !void {...@@ -181,6 +185,9 @@ fn make(step: *Step) !void {
181 child.stdout_behavior = stdIoActionToBehavior(self.stdout_action);185 child.stdout_behavior = stdIoActionToBehavior(self.stdout_action);
182 child.stderr_behavior = stdIoActionToBehavior(self.stderr_action);186 child.stderr_behavior = stdIoActionToBehavior(self.stderr_action);
183187
188 if (self.print)
189 printCmd(cwd, argv);
190
184 child.spawn() catch |err| {191 child.spawn() catch |err| {
185 warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) });192 warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) });
186 return err;193 return err;