mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
std.debug.lockStderrWriter: also return ttyconf
`std.Io.tty.Config.detect` may be an expensive check (e.g. involving syscalls), and doing it every time we need to print isn't really necessary; under normal usage, we can compute the value once and cache it for the whole program's execution. Since anyone outputting to stderr may reasonably want this information (in fact they are very likely to), it makes sense to cache it and return it from `lockStderrWriter`. Call sites who do not need it will experience no significant overhead, and can just ignore the TTY config with a `const w, _` destructure.
This commit is contained in:
@@ -1056,15 +1056,15 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking
|
||||
const maybe_path: ?*GeneratedFile = @field(compile, tag_name);
|
||||
|
||||
const generated_file = maybe_path orelse {
|
||||
const w = std.debug.lockStderrWriter(&.{});
|
||||
std.Build.dumpBadGetPathHelp(&compile.step, w, .detect(.stderr()), compile.step.owner, asking_step) catch {};
|
||||
const w, const ttyconf = std.debug.lockStderrWriter(&.{});
|
||||
std.Build.dumpBadGetPathHelp(&compile.step, w, ttyconf, compile.step.owner, asking_step) catch {};
|
||||
std.debug.unlockStderrWriter();
|
||||
@panic("missing emit option for " ++ tag_name);
|
||||
};
|
||||
|
||||
const path = generated_file.path orelse {
|
||||
const w = std.debug.lockStderrWriter(&.{});
|
||||
std.Build.dumpBadGetPathHelp(&compile.step, w, .detect(.stderr()), compile.step.owner, asking_step) catch {};
|
||||
const w, const ttyconf = std.debug.lockStderrWriter(&.{});
|
||||
std.Build.dumpBadGetPathHelp(&compile.step, w, ttyconf, compile.step.owner, asking_step) catch {};
|
||||
std.debug.unlockStderrWriter();
|
||||
@panic(tag_name ++ " is null. Is there a missing step dependency?");
|
||||
};
|
||||
@@ -2027,10 +2027,9 @@ fn checkCompileErrors(compile: *Compile) !void {
|
||||
var aw: std.Io.Writer.Allocating = .init(arena);
|
||||
defer aw.deinit();
|
||||
try actual_eb.renderToWriter(.{
|
||||
.ttyconf = .no_color,
|
||||
.include_reference_trace = false,
|
||||
.include_source_line = false,
|
||||
}, &aw.writer);
|
||||
}, &aw.writer, .no_color);
|
||||
break :ae try aw.toOwnedSlice();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user