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,
3737
3838expected_exit_code: u8 = 0,
3939
40/// Print the command before running it
41print: bool,
42
4043pub const StdIoAction = union(enum) {
4144 inherit,
4245 ignore,
......@@ -58,6 +61,7 @@ pub fn create(builder: *Builder, name: []const u8) *RunStep {
5861 .argv = ArrayList(Arg).init(builder.allocator),
5962 .cwd = null,
6063 .env_map = null,
64 .print = builder.verbose,
6165 };
6266 return self;
6367}
......@@ -181,6 +185,9 @@ fn make(step: *Step) !void {
181185 child.stdout_behavior = stdIoActionToBehavior(self.stdout_action);
182186 child.stderr_behavior = stdIoActionToBehavior(self.stderr_action);
183187
188 if (self.print)
189 printCmd(cwd, argv);
190
184191 child.spawn() catch |err| {
185192 warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) });
186193 return err;