Skip to content

Commit

Permalink
zig-build: remove duplicate emsdk_includes
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Jan 19, 2025
1 parent 3faf1c0 commit b531649
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,19 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep {
lib.root_module.root_source_file = b.path("src/handmade/math.zig");
if (options.optimize != .Debug)
lib.want_lto = true;

// make sure we're building for the wasm32-emscripten target, not wasm32-freestanding
if (lib.rootModuleTarget().os.tag != .emscripten) {
std.log.err("Please build with 'zig build -Dtarget=wasm32-emscripten", .{});
return error.Wasm32EmscriptenExpected;
}
// one-time setup of Emscripten SDK
if (!options.with_sokol_imgui) {
if (options.emsdk) |emsdk| {
if (try emSdkSetupStep(b, emsdk)) |emsdk_setup| {
lib.step.dependOn(&emsdk_setup.step);
}
// add the Emscripten system include seach path
lib.addIncludePath(emSdkLazyPath(b, emsdk, &.{ "upstream", "emscripten", "cache", "sysroot", "include" }));
if (options.emsdk) |emsdk| {
if (try emSdkSetupStep(b, emsdk)) |emsdk_setup| {
lib.step.dependOn(&emsdk_setup.step);
}
// add the Emscripten system include seach path
lib.addSystemIncludePath(emSdkLazyPath(b, emsdk, &.{ "upstream", "emscripten", "cache", "sysroot", "include" }));
}
}

Expand Down Expand Up @@ -204,6 +203,9 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep {
.use_tsan = lib.root_module.sanitize_thread orelse false,
.use_ubsan = lib.root_module.sanitize_c orelse false,
});
if (options.emsdk) |emsdk| {
imgui.addSystemIncludePath(emSdkLazyPath(b, emsdk, &.{ "upstream", "emscripten", "cache", "sysroot", "include" }));
}
for (imgui.root_module.include_dirs.items) |dir| {
try lib.root_module.include_dirs.append(b.allocator, dir);
}
Expand Down Expand Up @@ -1197,21 +1199,6 @@ fn buildImgui(b: *Build, options: libImGuiOptions) !*CompileStep {
const imgui = dep.path(imguiver_path);
libimgui.addIncludePath(imgui);

if (options.emsdk) |emsdk| {
if (libimgui.rootModuleTarget().isWasm()) {
if (try emSdkSetupStep(b, emsdk)) |emsdk_setup| {
libimgui.step.dependOn(&emsdk_setup.step);
}
// add the Emscripten system include seach path
libimgui.addIncludePath(emSdkLazyPath(b, emsdk, &.{
"upstream",
"emscripten",
"cache",
"sysroot",
"include",
}));
}
}
libimgui.addCSourceFiles(.{
.root = imgui,
.files = &.{
Expand Down

0 comments on commit b531649

Please sign in to comment.