63 lines
2.0 KiB
Zig
63 lines
2.0 KiB
Zig
const std = @import("std");
|
|
const raylib = @import("libs/raylib/build.zig");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
// TODO: Figure out how to build project for WASM. Tried to do it but standard memory allocators
|
|
// didn't work.
|
|
|
|
const exe = b.addExecutable(.{
|
|
.name = "chip8-zig",
|
|
.root_source_file = .{ .path = "src/main.zig" },
|
|
.optimize = optimize,
|
|
.target = target
|
|
});
|
|
|
|
exe.addModule("zgltf", b.createModule(.{
|
|
.source_file = .{ .path = "libs/zgltf/src/main.zig" },
|
|
}));
|
|
|
|
// Provide filenames of all files in 'src/ROMs' to program as options
|
|
{
|
|
var files = std.ArrayList([]const u8).init(b.allocator);
|
|
defer files.deinit();
|
|
var options = b.addOptions();
|
|
var dir = try std.fs.cwd().openIterableDir("src/ROMs", .{ });
|
|
var it = dir.iterate();
|
|
while (try it.next()) |file| {
|
|
if (file.kind != .file) {
|
|
continue;
|
|
}
|
|
try files.append(b.pathJoin(&.{"ROMs", file.name}));
|
|
}
|
|
|
|
options.addOption([]const []const u8, "roms", files.items);
|
|
exe.addOptions("options", options);
|
|
}
|
|
|
|
raylib.addTo(b, exe, target, optimize);
|
|
|
|
{
|
|
var build_models_step = b.step("models", "Export .blend files");
|
|
var build_models = b.addSystemCommand(&[_][]const u8{ "blender" });
|
|
build_models.addFileArg(.{ .path = "src/assets/models/emulator.blend" });
|
|
build_models.addArg("--background");
|
|
build_models.addArg("--python");
|
|
build_models.addFileArg(.{ .path = "src/assets/models/export.py" });
|
|
build_models.addArg("--");
|
|
build_models.addArg("src/assets/models/emulator.glb");
|
|
|
|
build_models_step.dependOn(&build_models.step);
|
|
exe.step.dependOn(build_models_step);
|
|
}
|
|
|
|
const run_cmd = b.addRunArtifact(exe);
|
|
|
|
const run_step = b.step("run", "Run chip8-zig");
|
|
run_step.dependOn(&run_cmd.step);
|
|
|
|
b.installArtifact(exe);
|
|
}
|