Switch to sokol

This commit is contained in:
2025-11-08 17:43:11 +01:00
parent bf2c03b8d5
commit 1a3d52079b
51 changed files with 34 additions and 16843 deletions

View File

@@ -1,64 +1,39 @@
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 cimgui = @import("cimgui");
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,
});
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 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));
exe_mod.addImport("cimgui", cimgui_dep.module(cimgui_conf.module_name));
exe_mod.addImport("sokol", sokol_dep.module("sokol"));
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);