-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a build.zig and build.zig.zon file for use as Zig package
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ imgui-docking/ | |
dear_bindings/ | ||
build/ | ||
src*/*.json | ||
.zig-* | ||
zig-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const std = @import("std"); | ||
const builtin = @import("builtin"); | ||
|
||
pub fn build(b: *std.Build) void { | ||
const target = b.standardTargetOptions(.{}); | ||
const optimize = b.standardOptimizeOption(.{}); | ||
|
||
const lib_cimgui = b.addStaticLibrary(.{ | ||
.name = "cimgui_clib", | ||
.target = target, | ||
.optimize = optimize, | ||
.link_libc = true, | ||
}); | ||
lib_cimgui.linkLibCpp(); | ||
lib_cimgui.addCSourceFiles(.{ | ||
.files = &.{ | ||
"src/cimgui.cpp", | ||
"src/imgui_demo.cpp", | ||
"src/imgui_draw.cpp", | ||
"src/imgui_tables.cpp", | ||
"src/imgui_widgets.cpp", | ||
"src/imgui.cpp", | ||
}, | ||
}); | ||
|
||
// make cimgui available as artifact, this allows to inject | ||
// the Emscripten sysroot include path in another build.zig | ||
b.installArtifact(lib_cimgui); | ||
|
||
// translate-c the cimgui.h file | ||
// NOTE: running this step with the host target is intended to avoid | ||
// any Emscripten header search path shenanigans | ||
const translateC = b.addTranslateC(.{ | ||
.root_source_file = b.path("src/cimgui.h"), | ||
.target = b.host, | ||
.optimize = optimize, | ||
}); | ||
|
||
// build cimgui as module | ||
const mod_cimgui = b.addModule("cimgui", .{ | ||
.root_source_file = translateC.getOutput(), | ||
.target = target, | ||
.optimize = optimize, | ||
.link_libc = true, | ||
.link_libcpp = true, | ||
}); | ||
mod_cimgui.linkLibrary(lib_cimgui); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.{ | ||
.name = "cimgui", | ||
.version = "0.1.0", | ||
.paths = .{ | ||
"src", | ||
"src-docking", | ||
"build.zig", | ||
"build.zig.zon", | ||
}, | ||
} |