87 lines
2.8 KiB
Zig
87 lines
2.8 KiB
Zig
const std = @import("std");
|
|
|
|
pub const Backends = enum {
|
|
allegro5,
|
|
android,
|
|
dx10,
|
|
dx11,
|
|
dx12,
|
|
dx9,
|
|
glfw,
|
|
glut,
|
|
null,
|
|
opengl2,
|
|
opengl3,
|
|
sdl2,
|
|
sdl3,
|
|
sdlgpu3,
|
|
sdlrenderer2,
|
|
sdlrenderer3,
|
|
vulkan,
|
|
wgpu,
|
|
win32,
|
|
};
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const backends = b.option([]Backends, "backends", "which backends to use (compatibility of backends is not assured, the user is held responsible to check if the backends works togeather)") orelse &.{Backends.null};
|
|
const internal = b.option(bool, "internal", "also add the internal definitions") orelse false;
|
|
const linkage = b.option(std.builtin.LinkMode, "linkage", "how to link the lib");
|
|
|
|
const dear_bindings = b.dependency("dear_bindings", .{});
|
|
const imgui = b.dependency("imgui", .{});
|
|
|
|
const mod = b.addModule("imgui", .{
|
|
.optimize = optimize,
|
|
.target = target,
|
|
.link_libcpp = true,
|
|
});
|
|
|
|
mod.addCSourceFile(.{ .file = dear_bindings.path("dcimgui.cpp"), .language = .cpp });
|
|
mod.addCSourceFile(.{ .file = imgui.path("imgui.cpp"), .language = .cpp });
|
|
mod.addIncludePath(imgui.path("."));
|
|
mod.addIncludePath(dear_bindings.path("."));
|
|
if (internal) {
|
|
mod.addCSourceFile(.{ .file = dear_bindings.path("dcimgui_internal.cpp"), .language = .cpp });
|
|
mod.addCSourceFile(.{ .file = imgui.path("imgui_internal.cpp"), .language = .cpp });
|
|
}
|
|
|
|
mod.addIncludePath(imgui.path("backends"));
|
|
mod.addIncludePath(dear_bindings.path("backends"));
|
|
for (backends) |backend|
|
|
switch (backend) {
|
|
inline else => |e| {
|
|
const file = "imgui_impl_" ++ @tagName(e) ++ ".cpp";
|
|
|
|
mod.addCSourceFile(.{ .file = dear_bindings.path("backends/dc" ++ file), .language = .cpp });
|
|
mod.addCSourceFile(.{ .file = imgui.path("backends/" ++ file), .language = .cpp });
|
|
},
|
|
};
|
|
|
|
if (linkage) |l| {
|
|
const lib = b.addLibrary(.{
|
|
.name = "imgui_zig",
|
|
.root_module = mod,
|
|
.version = .{ .major = 1, .minor = 92, .patch = 8 },
|
|
.linkage = l,
|
|
});
|
|
b.installArtifact(lib);
|
|
} else {
|
|
const liba = b.addLibrary(.{
|
|
.name = "imgui_zig",
|
|
.root_module = mod,
|
|
.version = .{ .major = 1, .minor = 92, .patch = 8 },
|
|
.linkage = .static,
|
|
});
|
|
b.installArtifact(liba);
|
|
const libso = b.addLibrary(.{
|
|
.name = "imgui_zig",
|
|
.root_module = mod,
|
|
.version = .{ .major = 1, .minor = 92, .patch = 8 },
|
|
.linkage = .dynamic,
|
|
});
|
|
b.installArtifact(libso);
|
|
}
|
|
}
|