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 {
const remove_dir_step = self.allocator.create(Step.RemoveDir) catch @panic("OOM");
remove_dir_step.* = Step.RemoveDir.init(self, dir_path);
return remove_dir_step;
return Step.RemoveDir.create(self, dir_path);
}
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,
dir_path: []const u8,
pub fn init(owner: *std.Build, dir_path: []const u8) RemoveDir {
return RemoveDir{
pub fn create(owner: *std.Build, dir_path: []const u8) *RemoveDir {
const self = owner.allocator.create(RemoveDir) catch @panic("OOM");
self.* = .{
.step = Step.init(.{
.id = .remove_dir,
.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),
};
return self;
}
fn make(step: *Step, prog_node: *std.Progress.Node) !void {