79 lines
2.3 KiB
Zig
79 lines
2.3 KiB
Zig
const std = @import("std");
|
|
|
|
// 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 mod = b.addModule("cimgui", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
.root_source_file = b.path("src/cimgui.zig"),
|
|
});
|
|
|
|
mod.addIncludePath(b.path("cimgui/imgui"));
|
|
mod.addIncludePath(b.path("cimgui/SDL/include"));
|
|
mod.addIncludePath(b.path("cimplot"));
|
|
mod.addIncludePath(b.path("cimplot/implot"));
|
|
|
|
const cimgui = b.addStaticLibrary(.{
|
|
.name = "cimgui",
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
cimgui.linkLibC();
|
|
|
|
if (target.result.abi != .msvc)
|
|
cimgui.linkLibCpp();
|
|
|
|
cimgui.addIncludePath(b.path("cimgui"));
|
|
cimgui.addIncludePath(b.path("cimplot"));
|
|
cimgui.addIncludePath(b.path("cimgui/imgui"));
|
|
cimgui.addIncludePath(b.path("cimgui/imgui/backends"));
|
|
cimgui.addIncludePath(b.path("cimgui/imgui/backends"));
|
|
cimgui.addIncludePath(b.path("cimgui/SDL/include/"));
|
|
|
|
cimgui.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.addCSourceFiles(.{
|
|
.root = b.path("cimplot"),
|
|
.files = &[_][]const u8{
|
|
"cimplot.cpp",
|
|
"implot/implot.cpp",
|
|
"implot/implot_demo.cpp",
|
|
"implot/implot_items.cpp",
|
|
},
|
|
});
|
|
|
|
mod.linkLibrary(cimgui);
|
|
|
|
// 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(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.root_source_file = b.path("tests/tests.zig"),
|
|
});
|
|
|
|
tests.root_module.addImport("cimgui", mod);
|
|
const runArtifact = b.addRunArtifact(tests);
|
|
test_step.dependOn(&runArtifact.step);
|
|
b.installArtifact(tests);
|
|
}
|