aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-05-27 15:41:47 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-05-27 20:56:49 -0700
commitb7889f262a5bee642460eb33b1ae7f2b1f87864c (patch)
tree2a159975546426872285a309424494fa6d2476b4 /src
parentaca7feb8fac2fae8f0b79a2cfac2a248bcd8451b (diff)
downloadzig-b7889f262a5bee642460eb33b1ae7f2b1f87864c.tar.gz
zig-b7889f262a5bee642460eb33b1ae7f2b1f87864c.zip
zig build: respect --color argument
`--color off` now disables the CLI progress bar both in the parent process and the build runner process.
Diffstat (limited to 'src')
-rw-r--r--src/main.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 987a7cec5a..cec15a087f 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -4702,6 +4702,8 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
const results_tmp_file_nonce = Package.Manifest.hex64(std.crypto.random.int(u64));
try child_argv.append("-Z" ++ results_tmp_file_nonce);
+ var color: Color = .auto;
+
{
var i: usize = 0;
while (i < args.len) : (i += 1) {
@@ -4786,6 +4788,14 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
verbose_cimport = true;
} else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
verbose_llvm_cpu_features = true;
+ } else if (mem.eql(u8, arg, "--color")) {
+ if (i + 1 >= args.len) fatal("expected [auto|on|off] after {s}", .{arg});
+ i += 1;
+ color = std.meta.stringToEnum(Color, args[i]) orelse {
+ fatal("expected [auto|on|off] after {s}, found '{s}'", .{ arg, args[i] });
+ };
+ try child_argv.appendSlice(&.{ arg, args[i] });
+ continue;
} else if (mem.eql(u8, arg, "--seed")) {
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
i += 1;
@@ -4799,7 +4809,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
const work_around_btrfs_bug = native_os == .linux and
EnvVar.ZIG_BTRFS_WORKAROUND.isSet();
- const color: Color = .auto;
const root_prog_node = std.Progress.start(.{
.disable_printing = (color == .off),
.root_name = "Compile Build Script",