mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
* Step.init() now takes an options struct * Step.init() now captures a small stack trace and stores it in the Step so that it can be accessed when printing user-friendly debugging information, including the lines of code that created the step in question.
27 lines
641 B
Zig
27 lines
641 B
Zig
const std = @import("../std.zig");
|
|
const log = std.log;
|
|
const Step = std.Build.Step;
|
|
const LogStep = @This();
|
|
|
|
pub const base_id = .log;
|
|
|
|
step: Step,
|
|
builder: *std.Build,
|
|
data: []const u8,
|
|
|
|
pub fn init(builder: *std.Build, data: []const u8) LogStep {
|
|
return LogStep{
|
|
.builder = builder,
|
|
.step = Step.init(builder.allocator, .{
|
|
.id = .log,
|
|
.name = builder.fmt("log {s}", .{data}),
|
|
.makeFn = make,
|
|
}),
|
|
.data = builder.dupe(data),
|
|
};
|
|
}
|
|
|
|
fn make(step: *Step) anyerror!void {
|
|
const self = @fieldParentPtr(LogStep, "step", step);
|
|
log.info("{s}", .{self.data});
|
|
}
|