const std = @import("std"); const zon = @import("build.zig.zon"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const llvm = b.option(bool, "llvm", "Use LLVM and LLD") orelse false; const media_dep = b.dependency("media", .{ .target = target, }); const vecmath_dep = b.dependency("vecmath", .{ .target = target, }); const vulkan_dep = b.dependency("vulkan_zig", .{ .target = target, .optimize = optimize, .registry = b.path("vendor/vk.xml"), }); const zglfw_dep = b.dependency("zglfw", .{ .target = target, .optimize = optimize, .import_vulkan = true, }); const media_mod = media_dep.module("media"); const vecmath_mod = vecmath_dep.module("vecmath"); const vulkan_mod = vulkan_dep.module("vulkan-zig"); const zglfw_mod = zglfw_dep.module("root"); zglfw_mod.addImport("vulkan", vulkan_mod); const zglfw_lib = zglfw_dep.artifact("glfw"); const exe_mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); exe_mod.addImport("media", media_mod); exe_mod.addImport("vecmath", vecmath_mod); exe_mod.addImport("vulkan", vulkan_mod); exe_mod.addImport("zglfw", zglfw_mod); exe_mod.linkLibrary(zglfw_lib); const options = b.addOptions(); options.addOption([]const u8, "version", zon.version); exe_mod.addOptions("config", options); const exe = b.addExecutable(.{ .name = "voxel-game", .root_module = exe_mod, .use_llvm = llvm, .use_lld = llvm, }); 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); }