mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
std/build: support --color
This commit is contained in:
parent
ea45ee5484
commit
f01c3150c1
@ -45,6 +45,7 @@ pub const Builder = struct {
|
||||
verbose_llvm_ir: bool,
|
||||
verbose_cimport: bool,
|
||||
verbose_llvm_cpu_features: bool,
|
||||
color: enum { auto, on, off } = .auto,
|
||||
invalid_user_input: bool,
|
||||
zig_exe: []const u8,
|
||||
default_step: *Step,
|
||||
@ -1946,6 +1947,11 @@ pub const LibExeObjStep = struct {
|
||||
};
|
||||
zig_args.append(cmd) catch unreachable;
|
||||
|
||||
if (builder.color != .auto) {
|
||||
try zig_args.append("--color");
|
||||
try zig_args.append(@tagName(builder.color));
|
||||
}
|
||||
|
||||
if (self.root_src) |root_src| try zig_args.append(root_src.getPath(builder));
|
||||
|
||||
var prev_has_extra_flags = false;
|
||||
|
||||
@ -82,6 +82,15 @@ pub fn main() !void {
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
builder.addSearchPrefix(search_prefix);
|
||||
} else if (mem.eql(u8, arg, "--color")) {
|
||||
const next_arg = nextArg(args, &arg_idx) orelse {
|
||||
warn("expected [auto|on|off] after --color", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
builder.color = std.meta.stringToEnum(@TypeOf(builder.color), next_arg) orelse {
|
||||
warn("expected [auto|on|off] after --color, found '{}'", .{next_arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--override-lib-dir")) {
|
||||
builder.override_lib_dir = nextArg(args, &arg_idx) orelse {
|
||||
warn("Expected argument after --override-lib-dir\n\n", .{});
|
||||
@ -171,6 +180,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
|
||||
\\ --verbose Print commands before executing them
|
||||
\\ --prefix [path] Override default install prefix
|
||||
\\ --search-prefix [path] Add a path to look for binaries, libraries, headers
|
||||
\\ --color [auto|off|on] Enable or disable colored error messages
|
||||
\\
|
||||
\\Project-Specific Options:
|
||||
\\
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user