treesummaryrefslogcommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorPatrick2026-09-26 12:48:51 +0200
committerPatrick2026-09-26 12:48:51 +0200
commita58717ae1a2451635c7dee0970e6ee82b9cb4ac2 (patch)
tree65ba99ba7dd471433ae30a415ae50fa88023c1db /build.zig
downloadsg3-a58717ae1a2451635c7dee0970e6ee82b9cb4ac2.tar.gz
sg3-a58717ae1a2451635c7dee0970e6ee82b9cb4ac2.zip
add all
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig65
1 files changed, 65 insertions, 0 deletions
diff --git a/build.zig b/build.zig
new file mode 100644
index 0000000..1cf6415
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,65 @@
+const std = @import("std");
+const sokol = @import("sokol");
+const cimgui = @import("cimgui");
+const shdc = sokol.shdc;
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+
+ const cimgui_conf = cimgui.getConfig(true);
+
+ const dep_sokol = b.dependency("sokol", .{
+ .target = target,
+ .optimize = optimize,
+ .with_sokol_imgui = true,
+ .with_tracing = true,
+ });
+ const dep_cimgui = b.dependency("cimgui", .{
+ .target = target,
+ .optimize = optimize,
+ });
+
+ dep_sokol.artifact("sokol_clib").root_module.addIncludePath(dep_cimgui.path(cimgui_conf.include_dir));
+
+ const shader = shdc.createSourceFile(b, .{
+ .shdc_dep = b.dependency("shdc", .{}),
+ .input = "src/shaders/main.glsl",
+ .output = "src/shaders/main.glsl.zig",
+ .slang = .{
+ .glsl430 = true,
+ .glsl410 = false,
+ .glsl310es = true,
+ .glsl300es = false,
+ .metal_macos = true,
+ .hlsl5 = true,
+ .wgsl = true,
+ .spirv_vk = true,
+ },
+ .reflection = true,
+ }) catch undefined;
+
+ const exe = b.addExecutable(.{
+ .name = "rc2d",
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("src/main.zig"),
+ .target = target,
+ .optimize = optimize,
+ .imports = &.{
+ .{ .name = "sokol", .module = dep_sokol.module("sokol") },
+ .{ .name = cimgui_conf.module_name, .module = dep_cimgui.module(cimgui_conf.module_name) },
+ },
+ }),
+ });
+
+ exe.root_module.linkLibrary(dep_sokol.artifact("sokol_clib"));
+ exe.root_module.link_libc = true;
+ exe.step.dependOn(shader);
+
+ if (target.result.os.tag == .windows) {
+ exe.root_module.linkSystemLibrary("user32", .{});
+ exe.root_module.linkSystemLibrary("gdi32", .{});
+ }
+
+ b.installArtifact(exe);
+}