From 9c1c1d478d3f5a541c142bb32b22a77c2f500953 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Fri, 29 Oct 2021 14:03:00 -0600 Subject: [PATCH] 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. --- lib/std/build/RunStep.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/std/build/RunStep.zig b/lib/std/build/RunStep.zig index 4d366c3cdb952b90f28bfdcda73790c0022947bc..5b71280b350675b60ac9ee2226cc3795a5e7c2f5 100644 --- a/lib/std/build/RunStep.zig +++ b/lib/std/build/RunStep.zig @@ -37,6 +37,9 @@ stdin_behavior: std.ChildProcess.StdIo = .Inherit, expected_exit_code: u8 = 0, +/// Print the command before running it +print: bool, + pub const StdIoAction = union(enum) { inherit, ignore, @@ -58,6 +61,7 @@ pub fn create(builder: *Builder, name: []const u8) *RunStep { .argv = ArrayList(Arg).init(builder.allocator), .cwd = null, .env_map = null, + .print = builder.verbose, }; return self; } @@ -181,6 +185,9 @@ fn make(step: *Step) !void { child.stdout_behavior = stdIoActionToBehavior(self.stdout_action); child.stderr_behavior = stdIoActionToBehavior(self.stderr_action); + if (self.print) + printCmd(cwd, argv); + child.spawn() catch |err| { warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) }); return err; -- 2.54.0