tamamo/build.zig

54 lines
1.5 KiB
Zig

const std = @import("std");
fn mapgen(b: *std.build.Step) !void {
_ = b;
var alloc = std.heap.page_allocator;
const maps = [_][2][]const u8{
[2][]const u8{"./maps/dungeon.json", "./src/maps/dungeon.zig"},
[2][]const u8{"./maps/RPGmap.json", "./src/maps/rpg.zig"},
};
for (&maps) |map| {
var deno = std.ChildProcess.init(&.{"deno", "run", "-A", "./src/tools/genmap.js", map[0], map[1]}, alloc);
try deno.spawn();
_ = try deno.wait();
std.log.info("generated map {s}", .{map[1]});
}
}
fn release(b: *std.build.Step) !void {
_ = b;
var alloc = std.heap.page_allocator;
var rel = std.ChildProcess.init(&.{"bash", "./release.sh"}, alloc);
try rel.spawn();
_ = try rel.wait();
std.log.info("generated release assets in dist/{s}", .{""});
}
pub fn build(b: *std.build.Builder) !void {
const map_step = b.step("mapgen", "generate maps");
map_step.makeFn = mapgen;
const release_step = b.step("release", "generate release binaries");
release_step.makeFn = release;
release_step.dependOn(map_step);
const mode = b.standardReleaseOptions();
const lib = b.addSharedLibrary("cart", "src/main.zig", .unversioned);
//lib.step.dependOn(map_step);
lib.setBuildMode(mode);
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
lib.import_memory = true;
lib.initial_memory = 65536;
lib.max_memory = 65536;
lib.stack_size = 14752;
lib.export_symbol_names = &[_][]const u8{ "start", "update" };
lib.install();
}