zig/lib/std/Build/LogStep.zig
Andrew Kelley 02381c0372 std.Build: improve debugging of misconfigured steps
* 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.
2023-03-15 10:48:12 -07:00

28 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});
}