aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/WebServer.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2025-10-28 12:42:05 +0000
committerMatthew Lugg <mlugg@mlugg.co.uk>2025-10-30 09:31:28 +0000
commit74931fe25cdd94e1cd08b5ece9dcce19959bc079 (patch)
tree75449b1d594d55a872aeb03f2dd3be16ac396274 /lib/std/Build/WebServer.zig
parent74c23a237ef5245b63eb06b832a511aabeb715c0 (diff)
downloadzig-74931fe25cdd94e1cd08b5ece9dcce19959bc079.tar.gz
zig-74931fe25cdd94e1cd08b5ece9dcce19959bc079.zip
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.
Diffstat (limited to 'lib/std/Build/WebServer.zig')
-rw-r--r--lib/std/Build/WebServer.zig9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/std/Build/WebServer.zig b/lib/std/Build/WebServer.zig
index 50e304c950..4a136ccbf4 100644
--- a/lib/std/Build/WebServer.zig
+++ b/lib/std/Build/WebServer.zig
@@ -54,9 +54,9 @@ pub fn notifyUpdate(ws: *WebServer) void {
pub const Options = struct {
gpa: Allocator,
thread_pool: *std.Thread.Pool,
+ ttyconf: Io.tty.Config,
graph: *const std.Build.Graph,
all_steps: []const *Build.Step,
- ttyconf: Io.tty.Config,
root_prog_node: std.Progress.Node,
watch: bool,
listen_address: net.IpAddress,
@@ -101,10 +101,10 @@ pub fn init(opts: Options) WebServer {
return .{
.gpa = opts.gpa,
.thread_pool = opts.thread_pool,
+ .ttyconf = opts.ttyconf,
.graph = opts.graph,
.all_steps = all_steps,
.listen_address = opts.listen_address,
- .ttyconf = opts.ttyconf,
.root_prog_node = opts.root_prog_node,
.watch = opts.watch,
@@ -236,9 +236,9 @@ pub fn finishBuild(ws: *WebServer, opts: struct {
ws.gpa,
ws.graph.io,
ws.thread_pool,
+ ws.ttyconf,
ws.all_steps,
ws.root_prog_node,
- ws.ttyconf,
.{ .forever = .{ .ws = ws } },
) catch |err| std.process.fatal("failed to start fuzzer: {s}", .{@errorName(err)});
ws.fuzz.?.start();
@@ -655,8 +655,7 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
}
if (result_error_bundle.errorMessageCount() > 0) {
- const color = std.zig.Color.auto;
- result_error_bundle.renderToStdErr(color.renderOptions());
+ result_error_bundle.renderToStdErr(.{}, .auto);
log.err("the following command failed with {d} compilation errors:\n{s}", .{
result_error_bundle.errorMessageCount(),
try Build.Step.allocPrintCmd(arena, null, argv.items),