const std = @import("std"); pub fn build(b: *std.Build) void { const zaudio = b.dependency("zaudio", .{}); const zglfw = b.dependency("zglfw", .{}); const zgpu = b.dependency("zgpu", .{}); const zgui = b.dependency("zgui", .{ .shared = false, .backend = .glfw_wgpu, .with_implot = true, }); const zmath = b.dependency("zmath", .{}); const znoise = b.dependency("znoise", .{}); const zpool = b.dependency("zpool", .{}); const zstbi = b.dependency("zstbi", .{}); const ztracy = b.dependency("ztracy", .{ .enable_ztracy = b.option(bool, "tracy", "Enable Tracy profile markers") orelse false, .enable_fibers = b.option(bool, "tracy_fibers", "Enable Tracy fiber support") orelse false, .on_demand = b.option(bool, "tracy_on_demand", "Build Tracy with TRACY_ON_DEMAND") orelse false, }); const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const pipeline_debug = b.option(bool, "pipeline_debug", "Build asset pipeline in debug mode") orelse false; const pipeline_mod = b.createModule(.{ .root_source_file = b.path("pipeline/main.zig"), .target = b.graph.host, .optimize = if (pipeline_debug) .Debug else .ReleaseSafe, }); pipeline_mod.addImport("zstbi", zstbi.module("root")); const pipeline = b.addExecutable(.{ .name = "pipeline", .root_module = pipeline_mod, }); pipeline.linkLibrary(zstbi.artifact("zstbi")); const pipeline_cmd = b.addRunArtifact(pipeline); pipeline_cmd.setCwd(b.path(".")); const pipeline_step = b.step("pipeline", "Run the asset pipeline"); pipeline_step.dependOn(&pipeline_cmd.step); const exe_mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); exe_mod.addImport("zaudio", zaudio.module("root")); exe_mod.addImport("zglfw", zglfw.module("root")); exe_mod.addImport("zgpu", zgpu.module("root")); exe_mod.addImport("zgui", zgui.module("root")); exe_mod.addImport("zmath", zmath.module("root")); exe_mod.addImport("znoise", znoise.module("root")); exe_mod.addImport("zpool", zpool.module("root")); exe_mod.addImport("zstbi", zstbi.module("root")); exe_mod.addImport("ztracy", ztracy.module("root")); const exe = b.addExecutable(.{ .name = "voxel-game", .root_module = exe_mod, }); exe.linkLibrary(zaudio.artifact("miniaudio")); exe.linkLibrary(zgui.artifact("imgui")); exe.linkLibrary(znoise.artifact("FastNoiseLite")); exe.linkLibrary(zstbi.artifact("zstbi")); exe.linkLibrary(ztracy.artifact("tracy")); if (target.result.os.tag != .emscripten) { exe.linkLibrary(zglfw.artifact("glfw")); exe.linkLibrary(zgpu.artifact("zdawn")); } if (optimize != .Debug) { exe.subsystem = .Windows; } @import("zgpu").addLibraryPathsTo(exe); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step("run", "Run the game"); run_step.dependOn(&run_cmd.step); }