79 lines
2.5 KiB
Zig
79 lines
2.5 KiB
Zig
const std = @import("std");
|
|
const bh = @import("bh");
|
|
|
|
// very tiny, not intended to build anything just to run tests linked with libc
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
|
|
|
const cimgui = bh.MakeModLib(b, .{
|
|
.name = "cimgui",
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.static_build = static_build,
|
|
});
|
|
|
|
cimgui.install();
|
|
|
|
cimgui.mod.addIncludePath(b.path("cimgui/SDL/include"));
|
|
cimgui.mod.addIncludePath(b.path("cimplot"));
|
|
cimgui.mod.addIncludePath(b.path("cimgui/imgui"));
|
|
cimgui.mod.addIncludePath(b.path("cimplot/implot"));
|
|
|
|
cimgui.lib.linkLibC();
|
|
|
|
if (target.result.abi != .msvc)
|
|
cimgui.lib.linkLibCpp();
|
|
|
|
cimgui.lib.addIncludePath(b.path("cimgui"));
|
|
cimgui.lib.addIncludePath(b.path("cimplot"));
|
|
cimgui.lib.addIncludePath(b.path("cimgui/imgui"));
|
|
cimgui.lib.addIncludePath(b.path("cimgui/imgui/backends"));
|
|
cimgui.lib.addIncludePath(b.path("cimgui/imgui/backends"));
|
|
cimgui.lib.addIncludePath(b.path("cimgui/SDL/include/"));
|
|
|
|
cimgui.lib.addCSourceFiles(.{
|
|
.root = b.path("cimgui/imgui"),
|
|
.files = &[_][]const u8{
|
|
"cimgui.cpp",
|
|
"cimgui_compat.cpp", // replace with cimgui_compat_sdlgpu
|
|
"imgui.cpp",
|
|
"imgui_demo.cpp",
|
|
"imgui_draw.cpp",
|
|
"imgui_tables.cpp",
|
|
"imgui_widgets.cpp",
|
|
"backends/imgui_impl_sdl3.cpp",
|
|
"backends/imgui_impl_sdlgpu3.cpp",
|
|
},
|
|
});
|
|
|
|
cimgui.lib.addCSourceFiles(.{
|
|
.root = b.path("cimplot"),
|
|
.files = &[_][]const u8{
|
|
"cimplot.cpp",
|
|
"implot/implot.cpp",
|
|
"implot/implot_demo.cpp",
|
|
"implot/implot_items.cpp",
|
|
},
|
|
});
|
|
|
|
// I could've made cimgui a seperate lib,
|
|
// I can seperate it out later if needed.
|
|
const test_step = b.step("test", "run unit tests for imgui");
|
|
const tests = b.addTest(.{
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.root_source_file = b.path("tests/tests.zig"),
|
|
}),
|
|
});
|
|
|
|
tests.root_module.addImport("cimgui", cimgui.mod);
|
|
tests.root_module.linkLibrary(cimgui.lib);
|
|
|
|
const runArtifact = b.addRunArtifact(tests);
|
|
test_step.dependOn(&runArtifact.step);
|
|
b.installArtifact(tests);
|
|
}
|