mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 15:19:07 +00:00
zig build: respect --color argument
`--color off` now disables the CLI progress bar both in the parent process and the build runner process.
This commit is contained in:
parent
aca7feb8fa
commit
b7889f262a
2 changed files with 14 additions and 3 deletions
|
|
@ -289,7 +289,9 @@ pub fn main() !void {
|
||||||
.windows_api => {},
|
.windows_api => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
const main_progress_node = std.Progress.start(.{});
|
const main_progress_node = std.Progress.start(.{
|
||||||
|
.disable_printing = (color == .off),
|
||||||
|
});
|
||||||
|
|
||||||
builder.debug_log_scopes = debug_log_scopes.items;
|
builder.debug_log_scopes = debug_log_scopes.items;
|
||||||
builder.resolveInstallPrefix(install_prefix, dir_list);
|
builder.resolveInstallPrefix(install_prefix, dir_list);
|
||||||
|
|
@ -1223,7 +1225,7 @@ fn cleanExit() void {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Color = enum { auto, off, on };
|
const Color = std.zig.Color;
|
||||||
const Summary = enum { all, new, failures, none };
|
const Summary = enum { all, new, failures, none };
|
||||||
|
|
||||||
fn get_tty_conf(color: Color, stderr: File) std.io.tty.Config {
|
fn get_tty_conf(color: Color, stderr: File) std.io.tty.Config {
|
||||||
|
|
|
||||||
11
src/main.zig
11
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));
|
const results_tmp_file_nonce = Package.Manifest.hex64(std.crypto.random.int(u64));
|
||||||
try child_argv.append("-Z" ++ results_tmp_file_nonce);
|
try child_argv.append("-Z" ++ results_tmp_file_nonce);
|
||||||
|
|
||||||
|
var color: Color = .auto;
|
||||||
|
|
||||||
{
|
{
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
while (i < args.len) : (i += 1) {
|
while (i < args.len) : (i += 1) {
|
||||||
|
|
@ -4786,6 +4788,14 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
|
||||||
verbose_cimport = true;
|
verbose_cimport = true;
|
||||||
} else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
|
} else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
|
||||||
verbose_llvm_cpu_features = true;
|
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")) {
|
} else if (mem.eql(u8, arg, "--seed")) {
|
||||||
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
|
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
|
||||||
i += 1;
|
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
|
const work_around_btrfs_bug = native_os == .linux and
|
||||||
EnvVar.ZIG_BTRFS_WORKAROUND.isSet();
|
EnvVar.ZIG_BTRFS_WORKAROUND.isSet();
|
||||||
const color: Color = .auto;
|
|
||||||
const root_prog_node = std.Progress.start(.{
|
const root_prog_node = std.Progress.start(.{
|
||||||
.disable_printing = (color == .off),
|
.disable_printing = (color == .off),
|
||||||
.root_name = "Compile Build Script",
|
.root_name = "Compile Build Script",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue