std.Build: use create() instead of init() for Step.RemoveDir

This commit is contained in:
snoire 2023-10-20 20:31:32 +08:00 committed by Veikka Tuominen
parent 809e7aa4fc
commit b403ca0aab
2 changed files with 5 additions and 5 deletions

View File

@ -971,9 +971,7 @@ pub fn addWriteFiles(b: *Build) *Step.WriteFile {
} }
pub fn addRemoveDirTree(self: *Build, dir_path: []const u8) *Step.RemoveDir { pub fn addRemoveDirTree(self: *Build, dir_path: []const u8) *Step.RemoveDir {
const remove_dir_step = self.allocator.create(Step.RemoveDir) catch @panic("OOM"); return Step.RemoveDir.create(self, dir_path);
remove_dir_step.* = Step.RemoveDir.init(self, dir_path);
return remove_dir_step;
} }
pub fn addFmt(b: *Build, options: Step.Fmt.Options) *Step.Fmt { pub fn addFmt(b: *Build, options: Step.Fmt.Options) *Step.Fmt {

View File

@ -8,8 +8,9 @@ pub const base_id = .remove_dir;
step: Step, step: Step,
dir_path: []const u8, dir_path: []const u8,
pub fn init(owner: *std.Build, dir_path: []const u8) RemoveDir { pub fn create(owner: *std.Build, dir_path: []const u8) *RemoveDir {
return RemoveDir{ const self = owner.allocator.create(RemoveDir) catch @panic("OOM");
self.* = .{
.step = Step.init(.{ .step = Step.init(.{
.id = .remove_dir, .id = .remove_dir,
.name = owner.fmt("RemoveDir {s}", .{dir_path}), .name = owner.fmt("RemoveDir {s}", .{dir_path}),
@ -18,6 +19,7 @@ pub fn init(owner: *std.Build, dir_path: []const u8) RemoveDir {
}), }),
.dir_path = owner.dupePath(dir_path), .dir_path = owner.dupePath(dir_path),
}; };
return self;
} }
fn make(step: *Step, prog_node: *std.Progress.Node) !void { fn make(step: *Step, prog_node: *std.Progress.Node) !void {