zig/lib/std/Build/Step
Matthew Lugg c6b5945356 std.Build: don't force all children to inherit color option
The build runner was previously forcing child processes to have their
stderr colorization match the build runner by setting `CLICOLOR_FORCE`
or `NO_COLOR`. This is a nice idea in some cases---for instance a simple
`Run` step which we just expect to exit with code 0 and whose stderr is
not being programmatically inspected---but is a bad idea in others, for
instance if there is a check on stderr or if stderr is captured, in
which case forcing color on the child could cause checks to fail.

Instead, this commit adds a field to `std.Build.Step.Run` which
specifies a behavior for the build runner to employ in terms of
assigning the `CLICOLOR_FORCE` and `NO_COLOR` environment variables. The
default behavior is to set `CLICOLOR_FORCE` if the build runner's output
is colorized and the step's stderr is not captured, and to set
`NO_COLOR` otherwise. Alternatively, colors can be always enabled,
always disabled, always match the build runner, or the environment
variables can be left untouched so they can be manually controlled
through `env_map`.

Notably, this fixes a failure when running `zig build test-cli` in a
TTY (or with colors explicitly enabled). GitHub CI hadn't caught this
because it does not request color, but Codeberg CI now does, and we were
seeing a failure in the `zig init` test because the actual output had
color escape codes in it due to 6d280dc.
2025-11-14 21:50:24 +01:00
..
CheckFile.zig rework std.Io.Writer.Allocating to support runtime-known alignment 2025-08-30 00:48:50 -07:00
CheckObject.zig std: fixes 2025-09-30 13:44:51 +01:00
Compile.zig Move/coalesce RcIncludes enum to std.zig.RcIncludes 2025-11-07 19:16:52 -08:00
ConfigHeader.zig rework std.Io.Writer.Allocating to support runtime-known alignment 2025-08-30 00:48:50 -07:00
Fail.zig make zig compiler processes live across rebuilds 2024-07-14 19:51:16 -07:00
Fmt.zig std.Build: separate errors from failed commands 2025-10-18 09:28:42 +01:00
InstallArtifact.zig std.fmt: breaking API changes 2025-07-07 22:43:51 -07:00
InstallDir.zig std.fmt: breaking API changes 2025-07-07 22:43:51 -07:00
InstallFile.zig Build: add install commands to --verbose output 2025-06-19 11:45:06 -04:00
ObjCopy.zig std.Io: delete GenericReader 2025-08-29 17:14:26 -07:00
Options.zig std: updating to std.Io interface 2025-10-29 06:20:48 -07:00
RemoveDir.zig make zig compiler processes live across rebuilds 2024-07-14 19:51:16 -07:00
Run.zig std.Build: don't force all children to inherit color option 2025-11-14 21:50:24 +01:00
TranslateC.zig std.Build.Step.TranslateC: forward --cache-dir and --global-cache-dir flags 2025-08-26 03:54:00 +00:00
UpdateSourceFiles.zig std: updating to std.Io interface 2025-10-29 06:20:48 -07:00
WriteFile.zig std: updating to std.Io interface 2025-10-29 06:20:48 -07:00