summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorSteven Van Dorp <steven@vandorp.lu>2026-02-06 10:00:08 +0100
committerSteven Van Dorp <steven@vandorp.lu>2026-02-06 10:00:08 +0100
commit0d8aeb6464103ec8e35c10c448bf08b0b9edc156 (patch)
tree80ab47bf3e0f137856d8494753e774c8456c85c8 /build.zig
Initial CommitHEADmaster
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig50
1 files changed, 50 insertions, 0 deletions
diff --git a/build.zig b/build.zig
new file mode 100644
index 0000000..117aa04
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,50 @@
+const std = @import("std");
+
+const name = "minimgui";
+
+pub fn build(b: *std.Build) !void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+
+ const emit_exe = b.option(bool, "emit-exe", "emit executable file") orelse false;
+ const emit_lib = b.option(bool, "emit-lib", "emit shared object file") orelse false;
+ const strip = b.option(bool, "strip", "strip debug symbols") orelse true;
+
+ const mod = b.createModule(.{
+ .root_source_file = b.path(switch (target.result.os.tag) {
+ .linux => "src/linux.zig",
+ else => return error.UnsupportedOs,
+ }),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ .strip = strip,
+ });
+ mod.linkSystemLibrary("x11", .{});
+ mod.linkSystemLibrary("xext", .{});
+ mod.addIncludePath(b.path("lib/stb_image/"));
+ mod.addCSourceFile(.{.file = b.path("lib/stb_image/stb_image.c"), .flags = &.{}});
+ mod.addIncludePath(b.path("lib/stb_truetype/"));
+ mod.addCSourceFile(.{.file = b.path("lib/stb_truetype/stb_truetype.c"), .flags = &.{}});
+
+ const use_llvm = !strip or optimize != .Debug;
+ if (emit_exe) {
+ const exe = b.addExecutable(.{
+ .name = name,
+ .root_module = mod,
+ .use_llvm = use_llvm,
+ });
+ b.installArtifact(exe);
+ }
+
+ if (emit_lib) {
+ const lib = b.addLibrary(.{
+ .name = name,
+ .root_module = mod,
+ .linkage = .dynamic,
+ .use_llvm = use_llvm,
+ });
+ b.installArtifact(lib);
+ }
+}
+