64 lines
1.7 KiB
Zig
64 lines
1.7 KiB
Zig
const std = @import("std");
|
|
|
|
const cimgui = @import("cimgui");
|
|
const sokol = @import("sokol");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const cimgui_conf = cimgui.getConfig(false);
|
|
|
|
const exe_mod = b.createModule(.{
|
|
.root_source_file = b.path("src/main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
const cimgui_dep = b.dependency("cimgui", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
const sokol_dep = b.dependency("sokol", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.with_sokol_imgui = true,
|
|
});
|
|
sokol_dep.artifact("sokol_clib").addIncludePath(cimgui_dep.path(cimgui_conf.include_dir));
|
|
|
|
const sokol_mod = sokol_dep.module("sokol");
|
|
const shdc_dep = sokol_dep.builder.dependency("shdc", .{});
|
|
|
|
const shaders_mod = try sokol.shdc.createModule(b, "shaders", sokol_mod, .{
|
|
.shdc_dep = shdc_dep,
|
|
.input = "assets/shaders.glsl",
|
|
.output = "shaders.zig",
|
|
.slang = .{
|
|
.glsl430 = true,
|
|
.hlsl5 = true,
|
|
.metal_macos = true,
|
|
},
|
|
});
|
|
|
|
exe_mod.addImport("cimgui", cimgui_dep.module(cimgui_conf.module_name));
|
|
exe_mod.addImport("shaders", shaders_mod);
|
|
exe_mod.addImport("sokol", sokol_mod);
|
|
|
|
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);
|
|
}
|