gb3dplatformer/build.zig

58 lines
1.9 KiB
Zig
Raw Normal View History

2024-04-17 11:22:06 -06:00
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const rgbds = b.dependency("rgbds", .{
.target = target,
.optimize = optimize,
});
const convert_tiles = b.addRunArtifact(rgbds.artifact("rgbgfx"));
convert_tiles.addArg("-u");
convert_tiles.addFileArg(.{ .path = "tilemap.png" });
convert_tiles.addArg("-o");
const tileset_bin = convert_tiles.addOutputFileArg("tileset.2bpp");
convert_tiles.addArg("-t");
const tileset_map = convert_tiles.addOutputFileArg("tileset.tilemap");
const convert_sprites = b.addRunArtifact(rgbds.artifact("rgbgfx"));
convert_sprites.addArg("-u");
convert_sprites.addFileArg(.{ .path = "sprites.png" });
convert_sprites.addArg("-o");
const sprites_bin = convert_sprites.addOutputFileArg("sprites.2bpp");
2024-04-17 11:22:06 -06:00
const assemble = b.addRunArtifact(rgbds.artifact("rgbasm"));
assemble.addArg("-L");
assemble.addArg("-o");
const main_obj = assemble.addOutputFileArg("main.o");
assemble.addFileArg(.{ .path = "main.asm" });
assemble.addArg("--include");
assemble.addDirectoryArg(tileset_bin.dirname());
assemble.addArg("--include");
assemble.addDirectoryArg(tileset_map.dirname());
assemble.addArg("--include");
assemble.addDirectoryArg(sprites_bin.dirname());
2024-04-17 11:22:06 -06:00
const link = b.addRunArtifact(rgbds.artifact("rgblink"));
link.addArg("-o");
const rom = link.addOutputFileArg("3dp.gb");
link.addFileArg(main_obj);
const fix = b.addRunArtifact(rgbds.artifact("rgbfix"));
fix.addArg("-v");
fix.addArg("-p");
fix.addArg("0xFF");
fix.addFileArg(rom);
const install_file = b.addInstallFile(rom, "3dp.gb");
install_file.step.dependOn(&fix.step);
const install = b.getInstallStep();
install.dependOn(&install_file.step);
}