Skip to content

Commit

Permalink
Fix ConvertMode4ImageStep with new build system
Browse files Browse the repository at this point in the history
Partially fix #12
  • Loading branch information
wendigojaeger committed Apr 30, 2023
1 parent 7bb6aa0 commit bfb70ba
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions GBA/builder.zig
Original file line number Diff line number Diff line change
Expand Up @@ -109,33 +109,37 @@ const Mode4ConvertStep = struct {
.id = .custom,
.name = b.fmt("ConvertMode4Image {s}", .{targetPalettePath}),
.owner = b,
.makeFn = make,
}),
.images = images,
.targetPalettePath = targetPalettePath,
};
}

fn make(step: *Step) !void {
fn make(step: *Step, progress_node: *std.Progress.Node) !void {
const self = @fieldParentPtr(Mode4ConvertStep, "step", step);
const ImageSourceTargetList = ArrayList(ImageSourceTarget);

var fullImages = ImageSourceTargetList.init(self.builder.allocator);
var fullImages = ImageSourceTargetList.init(step.owner.allocator);
defer fullImages.deinit();

var node = progress_node.start("Converting mode4 images", 1);
defer node.end();

for (self.images) |imageSourceTarget| {
try fullImages.append(ImageSourceTarget{
.source = self.step.owner.pathFromRoot(imageSourceTarget.source),
.target = self.step.owner.pathFromRoot(imageSourceTarget.target),
});
}
const fullTargetPalettePath = self.step.owner.pathFromRoot(self.targetPalettePath);

const fullTargetPalettePath = self.step.owner.pathFromRoot(self.targetPalettePath);
try ImageConverter.convertMode4Image(self.step.owner.allocator, fullImages.items, fullTargetPalettePath);
}
};

pub fn convertMode4Images(libExe: *std.build.CompileStep, images: []const ImageSourceTarget, targetPalettePath: []const u8) void {
const convertImageStep = libExe.step.owner.allocator.create(Mode4ConvertStep) catch unreachable;
convertImageStep.* = Mode4ConvertStep.init(libExe.step.owner, images, targetPalettePath);
libExe.step.dependOn(&convertImageStep.step);
pub fn convertMode4Images(compile_step: *std.build.CompileStep, images: []const ImageSourceTarget, targetPalettePath: []const u8) void {
const convertImageStep = compile_step.step.owner.allocator.create(Mode4ConvertStep) catch unreachable;
convertImageStep.* = Mode4ConvertStep.init(compile_step.step.owner, images, targetPalettePath);
compile_step.step.dependOn(&convertImageStep.step);
}

0 comments on commit bfb70ba

Please sign in to comment.