@@ -24,17 +24,17 @@ pub fn build(b: *std.Build) void {
24
24
bool ,
25
25
"with_implot" ,
26
26
"Build with bundled implot source" ,
27
- ) orelse true ,
27
+ ) orelse false ,
28
28
.with_gizmo = b .option (
29
29
bool ,
30
30
"with_gizmo" ,
31
31
"Build with bundled ImGuizmo tool" ,
32
- ) orelse true ,
32
+ ) orelse false ,
33
33
.with_node_editor = b .option (
34
34
bool ,
35
35
"with_node_editor" ,
36
36
"Build with bundled ImGui node editor" ,
37
- ) orelse true ,
37
+ ) orelse false ,
38
38
.with_te = b .option (
39
39
bool ,
40
40
"with_te" ,
@@ -104,12 +104,24 @@ pub fn build(b: *std.Build) void {
104
104
105
105
b .installArtifact (imgui );
106
106
107
+ const emscripten = target .result .os .tag == .emscripten ;
108
+ if (emscripten ) {
109
+ imgui .defineCMacro ("__EMSCRIPTEN__" , null );
110
+ // TODO: read from enviroment or `emcc --version`
111
+ imgui .defineCMacro ("__EMSCRIPTEN_major__" , "3" );
112
+ imgui .defineCMacro ("__EMSCRIPTEN_minor__" , "1" );
113
+ imgui .root_module .stack_protector = false ;
114
+ //imgui.root_module.disable_stack_probing = true;
115
+ }
116
+
107
117
imgui .addIncludePath (b .path ("libs" ));
108
118
imgui .addIncludePath (b .path ("libs/imgui" ));
109
119
110
- imgui .linkLibC ();
111
- if (target .result .abi != .msvc )
112
- imgui .linkLibCpp ();
120
+ if (! emscripten ) {
121
+ imgui .linkLibC ();
122
+ if (target .result .abi != .msvc )
123
+ imgui .linkLibCpp ();
124
+ }
113
125
114
126
imgui .addCSourceFile (.{
115
127
.file = b .path ("src/zgui.cpp" ),
@@ -254,11 +266,17 @@ pub fn build(b: *std.Build) void {
254
266
255
267
switch (options .backend ) {
256
268
.glfw_wgpu = > {
257
- if (b .lazyDependency ("zglfw" , .{})) | zglfw | {
258
- imgui .addIncludePath (zglfw .path ("libs/glfw/include" ));
259
- }
260
- if (b .lazyDependency ("zgpu" , .{})) | zgpu | {
261
- imgui .addIncludePath (zgpu .path ("libs/dawn/include" ));
269
+ if (emscripten ) {
270
+ imgui .addSystemIncludePath (.{
271
+ .cwd_relative = b .pathJoin (&.{ b .sysroot .? , "include" }),
272
+ });
273
+ } else {
274
+ if (b .lazyDependency ("zglfw" , .{})) | zglfw | {
275
+ imgui .addIncludePath (zglfw .path ("libs/glfw/include" ));
276
+ }
277
+ if (b .lazyDependency ("zgpu" , .{})) | zgpu | {
278
+ imgui .addIncludePath (zgpu .path ("libs/dawn/include" ));
279
+ }
262
280
}
263
281
imgui .addCSourceFiles (.{
264
282
.files = &.{
0 commit comments