master
1//! Fail the build with a given message.
2const std = @import("std");
3const Step = std.Build.Step;
4const Fail = @This();
5
6step: Step,
7error_msg: []const u8,
8
9pub const base_id: Step.Id = .fail;
10
11pub fn create(owner: *std.Build, error_msg: []const u8) *Fail {
12 const fail = owner.allocator.create(Fail) catch @panic("OOM");
13
14 fail.* = .{
15 .step = Step.init(.{
16 .id = base_id,
17 .name = "fail",
18 .owner = owner,
19 .makeFn = make,
20 }),
21 .error_msg = owner.dupe(error_msg),
22 };
23
24 return fail;
25}
26
27fn make(step: *Step, options: Step.MakeOptions) !void {
28 _ = options; // No progress to report.
29
30 const fail: *Fail = @fieldParentPtr("step", step);
31
32 try step.result_error_msgs.append(step.owner.allocator, fail.error_msg);
33
34 return error.MakeFailed;
35}