52 lines
1.5 KiB
Zig
52 lines
1.5 KiB
Zig
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 vulkan_dep = b.dependency("vulkan_zig", .{ .registry = b.path("vendor/vk.xml") });
|
|
const zglfw_dep = b.dependency("zglfw", .{ .import_vulkan = true });
|
|
const zstbi_dep = b.dependency("zstbi", .{});
|
|
|
|
const vulkan_mod = vulkan_dep.module("vulkan-zig");
|
|
const zglfw_mod = zglfw_dep.module("root");
|
|
const zstbi_mod = zstbi_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("vulkan", vulkan_mod);
|
|
exe_mod.addImport("zglfw", zglfw_mod);
|
|
exe_mod.addImport("zstbi", zstbi_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,
|
|
});
|
|
|
|
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);
|
|
}
|