@@ -239,6 +239,8 @@ pub fn build(b: *Build) !void {
239
239
b .getInstallStep ().dependOn (& ldc .step );
240
240
}
241
241
buildShaders (b );
242
+ const ll = buildImgui (b , .{ .target = target , .optimize = optimize });
243
+ b .installArtifact (ll );
242
244
}
243
245
244
246
// a separate step to compile shaders, expects the shader compiler in ../sokol-tools-bin/
@@ -434,7 +436,8 @@ fn ldcBuild(b: *Build, lib_sokol: *CompileStep, options: DCompileStep) !*RunStep
434
436
break ;
435
437
}
436
438
437
- // link flags
439
+ // linker flags
440
+
438
441
// GNU LD
439
442
if (options .target .result .os .tag == .linux and ! options .zig_cc ) {
440
443
try cmds .append ("-L--no-as-needed" );
@@ -538,3 +541,46 @@ const DCompileStep = struct {
538
541
fn packagePath (b : * Build , package : * Build.Dependency ) []const u8 {
539
542
return package .path ("" ).getPath (b );
540
543
}
544
+
545
+ fn buildImgui (b : * Build , options : struct { target : Build.ResolvedTarget , optimize : std .builtin .OptimizeMode }) * CompileStep {
546
+ const imgui_cpp = b .dependency ("imgui" , .{});
547
+ const imgui_cpp_dir = imgui_cpp .path ("" ).getPath (b );
548
+ const cimgui = b .dependency ("cimgui" , .{});
549
+ // const cimgui_dir = cimgui.path("").getPath(b);
550
+
551
+ const lib = b .addStaticLibrary (.{
552
+ .name = "imgui" ,
553
+ .target = options .target ,
554
+ .optimize = options .optimize ,
555
+ });
556
+ lib .addIncludePath (imgui_cpp .path ("" ));
557
+ lib .addIncludePath (cimgui .path ("" ));
558
+ lib .addCSourceFiles (.{
559
+ .files = &.{
560
+ b .pathJoin (&.{ imgui_cpp_dir , "imgui.cpp" }),
561
+ b .pathJoin (&.{ imgui_cpp_dir , "imgui_draw.cpp" }),
562
+ b .pathJoin (&.{ imgui_cpp_dir , "imgui_demo.cpp" }),
563
+ b .pathJoin (&.{ imgui_cpp_dir , "imgui_widgets.cpp" }),
564
+ b .pathJoin (&.{ imgui_cpp_dir , "imgui_tables.cpp" }),
565
+ // b.pathJoin(&.{ cimgui_dir, "cimgui.cpp" }),
566
+ },
567
+ .flags = &.{
568
+ "-Wall" ,
569
+ "-Wformat" ,
570
+ "-Wpedantic" ,
571
+ "-Wextra" ,
572
+ "-fno-exceptions" ,
573
+ "-fno-rtti" ,
574
+ },
575
+ });
576
+ lib .root_module .sanitize_c = false ;
577
+
578
+ // https://github.com/ziglang/zig/issues/5312
579
+ if (lib .rootModuleTarget ().abi != .msvc ) {
580
+ // llvm-libcxx + llvm-libunwind + os-libc
581
+ lib .linkLibCpp ();
582
+ } else {
583
+ lib .linkLibC ();
584
+ }
585
+ return lib ;
586
+ }
0 commit comments