Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions lib/build_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ const Run = struct {

claimed_rss: usize,
enable_summary: ?bool,
ttyconf: std.debug.TTY.Config,
ttyconf: std.io.tty.Config,
stderr: std.fs.File,
};

Expand Down Expand Up @@ -476,9 +476,9 @@ fn runStepNames(

if (run.enable_summary != false) {
const total_count = success_count + failure_count + pending_count + skipped_count;
ttyconf.setColor(stderr, .Cyan) catch {};
ttyconf.setColor(stderr, .cyan) catch {};
stderr.writeAll("Build Summary:") catch {};
ttyconf.setColor(stderr, .Reset) catch {};
ttyconf.setColor(stderr, .reset) catch {};
stderr.writer().print(" {d}/{d} steps succeeded", .{ success_count, total_count }) catch {};
if (skipped_count > 0) stderr.writer().print("; {d} skipped", .{skipped_count}) catch {};
if (failure_count > 0) stderr.writer().print("; {d} failed", .{failure_count}) catch {};
Expand All @@ -489,9 +489,9 @@ fn runStepNames(
if (test_leak_count > 0) stderr.writer().print("; {d} leaked", .{test_leak_count}) catch {};

if (run.enable_summary == null) {
ttyconf.setColor(stderr, .Dim) catch {};
ttyconf.setColor(stderr, .dim) catch {};
stderr.writeAll(" (disable with -fno-summary)") catch {};
ttyconf.setColor(stderr, .Reset) catch {};
ttyconf.setColor(stderr, .reset) catch {};
}
stderr.writeAll("\n") catch {};

Expand Down Expand Up @@ -535,7 +535,7 @@ const PrintNode = struct {
last: bool = false,
};

fn printPrefix(node: *PrintNode, stderr: std.fs.File, ttyconf: std.debug.TTY.Config) !void {
fn printPrefix(node: *PrintNode, stderr: std.fs.File, ttyconf: std.io.tty.Config) !void {
const parent = node.parent orelse return;
if (parent.parent == null) return;
try printPrefix(parent, stderr, ttyconf);
Expand All @@ -553,14 +553,14 @@ fn printTreeStep(
b: *std.Build,
s: *Step,
stderr: std.fs.File,
ttyconf: std.debug.TTY.Config,
ttyconf: std.io.tty.Config,
parent_node: *PrintNode,
step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void),
) !void {
const first = step_stack.swapRemove(s);
try printPrefix(parent_node, stderr, ttyconf);

if (!first) try ttyconf.setColor(stderr, .Dim);
if (!first) try ttyconf.setColor(stderr, .dim);
if (parent_node.parent != null) {
if (parent_node.last) {
try stderr.writeAll(switch (ttyconf) {
Expand All @@ -586,28 +586,28 @@ fn printTreeStep(
.running => unreachable,

.dependency_failure => {
try ttyconf.setColor(stderr, .Dim);
try ttyconf.setColor(stderr, .dim);
try stderr.writeAll(" transitive failure\n");
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
},

.success => {
try ttyconf.setColor(stderr, .Green);
try ttyconf.setColor(stderr, .green);
if (s.result_cached) {
try stderr.writeAll(" cached");
} else if (s.test_results.test_count > 0) {
const pass_count = s.test_results.passCount();
try stderr.writer().print(" {d} passed", .{pass_count});
if (s.test_results.skip_count > 0) {
try ttyconf.setColor(stderr, .Yellow);
try ttyconf.setColor(stderr, .yellow);
try stderr.writer().print(" {d} skipped", .{s.test_results.skip_count});
}
} else {
try stderr.writeAll(" success");
}
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
if (s.result_duration_ns) |ns| {
try ttyconf.setColor(stderr, .Dim);
try ttyconf.setColor(stderr, .dim);
if (ns >= std.time.ns_per_min) {
try stderr.writer().print(" {d}m", .{ns / std.time.ns_per_min});
} else if (ns >= std.time.ns_per_s) {
Expand All @@ -619,11 +619,11 @@ fn printTreeStep(
} else {
try stderr.writer().print(" {d}ns", .{ns});
}
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
}
if (s.result_peak_rss != 0) {
const rss = s.result_peak_rss;
try ttyconf.setColor(stderr, .Dim);
try ttyconf.setColor(stderr, .dim);
if (rss >= 1000_000_000) {
try stderr.writer().print(" MaxRSS:{d}G", .{rss / 1000_000_000});
} else if (rss >= 1000_000) {
Expand All @@ -633,57 +633,57 @@ fn printTreeStep(
} else {
try stderr.writer().print(" MaxRSS:{d}B", .{rss});
}
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
}
try stderr.writeAll("\n");
},

.skipped => {
try ttyconf.setColor(stderr, .Yellow);
try ttyconf.setColor(stderr, .yellow);
try stderr.writeAll(" skipped\n");
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
},

.failure => {
if (s.result_error_bundle.errorMessageCount() > 0) {
try ttyconf.setColor(stderr, .Red);
try ttyconf.setColor(stderr, .red);
try stderr.writer().print(" {d} errors\n", .{
s.result_error_bundle.errorMessageCount(),
});
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
} else if (!s.test_results.isSuccess()) {
try stderr.writer().print(" {d}/{d} passed", .{
s.test_results.passCount(), s.test_results.test_count,
});
if (s.test_results.fail_count > 0) {
try stderr.writeAll(", ");
try ttyconf.setColor(stderr, .Red);
try ttyconf.setColor(stderr, .red);
try stderr.writer().print("{d} failed", .{
s.test_results.fail_count,
});
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
}
if (s.test_results.skip_count > 0) {
try stderr.writeAll(", ");
try ttyconf.setColor(stderr, .Yellow);
try ttyconf.setColor(stderr, .yellow);
try stderr.writer().print("{d} skipped", .{
s.test_results.skip_count,
});
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
}
if (s.test_results.leak_count > 0) {
try stderr.writeAll(", ");
try ttyconf.setColor(stderr, .Red);
try ttyconf.setColor(stderr, .red);
try stderr.writer().print("{d} leaked", .{
s.test_results.leak_count,
});
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
}
try stderr.writeAll("\n");
} else {
try ttyconf.setColor(stderr, .Red);
try ttyconf.setColor(stderr, .red);
try stderr.writeAll(" failure\n");
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
}
},
}
Expand All @@ -703,7 +703,7 @@ fn printTreeStep(
s.dependencies.items.len,
});
}
try ttyconf.setColor(stderr, .Reset);
try ttyconf.setColor(stderr, .reset);
}
}

Expand Down Expand Up @@ -819,13 +819,13 @@ fn workerMakeOneStep(
for (s.result_error_msgs.items) |msg| {
// Sometimes it feels like you just can't catch a break. Finally,
// with Zig, you can.
ttyconf.setColor(stderr, .Bold) catch break;
ttyconf.setColor(stderr, .bold) catch break;
stderr.writeAll(s.owner.dep_prefix) catch break;
stderr.writeAll(s.name) catch break;
stderr.writeAll(": ") catch break;
ttyconf.setColor(stderr, .Red) catch break;
ttyconf.setColor(stderr, .red) catch break;
stderr.writeAll("error: ") catch break;
ttyconf.setColor(stderr, .Reset) catch break;
ttyconf.setColor(stderr, .reset) catch break;
stderr.writeAll(msg) catch break;
stderr.writeAll("\n") catch break;
}
Expand Down Expand Up @@ -1026,15 +1026,15 @@ fn cleanExit() void {

const Color = enum { auto, off, on };

fn get_tty_conf(color: Color, stderr: std.fs.File) std.debug.TTY.Config {
fn get_tty_conf(color: Color, stderr: std.fs.File) std.io.tty.Config {
return switch (color) {
.auto => std.debug.detectTTYConfig(stderr),
.auto => std.io.tty.detectConfig(stderr),
.on => .escape_codes,
.off => .no_color,
};
}

fn renderOptions(ttyconf: std.debug.TTY.Config) std.zig.ErrorBundle.RenderOptions {
fn renderOptions(ttyconf: std.io.tty.Config) std.zig.ErrorBundle.RenderOptions {
return .{
.ttyconf = ttyconf,
.include_source_line = ttyconf != .no_color,
Expand Down
14 changes: 7 additions & 7 deletions lib/std/Build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1712,10 +1712,10 @@ fn dumpBadGetPathHelp(
s.name,
});

const tty_config = std.debug.detectTTYConfig(stderr);
tty_config.setColor(w, .Red) catch {};
const tty_config = std.io.tty.detectConfig(stderr);
tty_config.setColor(w, .red) catch {};
try stderr.writeAll(" The step was created by this stack trace:\n");
tty_config.setColor(w, .Reset) catch {};
tty_config.setColor(w, .reset) catch {};

const debug_info = std.debug.getSelfDebugInfo() catch |err| {
try w.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)});
Expand All @@ -1727,19 +1727,19 @@ fn dumpBadGetPathHelp(
return;
};
if (asking_step) |as| {
tty_config.setColor(w, .Red) catch {};
tty_config.setColor(w, .red) catch {};
try stderr.writeAll(" The step that is missing a dependency on the above step was created by this stack trace:\n");
tty_config.setColor(w, .Reset) catch {};
tty_config.setColor(w, .reset) catch {};

std.debug.writeStackTrace(as.getStackTrace(), w, ally, debug_info, tty_config) catch |err| {
try stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)});
return;
};
}

tty_config.setColor(w, .Red) catch {};
tty_config.setColor(w, .red) catch {};
try stderr.writeAll(" Hope that helps. Proceeding to panic.\n");
tty_config.setColor(w, .Reset) catch {};
tty_config.setColor(w, .reset) catch {};
}

/// Allocates a new string for assigning a value to a named macro.
Expand Down
2 changes: 1 addition & 1 deletion lib/std/Build/Step.zig
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn dump(step: *Step) void {

const stderr = std.io.getStdErr();
const w = stderr.writer();
const tty_config = std.debug.detectTTYConfig(stderr);
const tty_config = std.io.tty.detectConfig(stderr);
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
w.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{
@errorName(err),
Expand Down
2 changes: 1 addition & 1 deletion lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub const StackTrace = struct {
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
return writer.print("\nUnable to print stack trace: Unable to open debug info: {s}\n", .{@errorName(err)});
};
const tty_config = std.debug.detectTTYConfig(std.io.getStdErr());
const tty_config = std.io.tty.detectConfig(std.io.getStdErr());
try writer.writeAll("\n");
std.debug.writeStackTrace(self, writer, arena.allocator(), debug_info, tty_config) catch |err| {
try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)});
Expand Down
Loading