Closed DanielKMach closed 22 hours ago
I found a way of getting the path without allocation.
const emcc_path = b.sysroot orelse return lib;
const emscripten_headers = b.pathJoin(&.{ emcc_path, "cache", "sysroot", "include" });
I can revert the last change and apply this solution if you want.
When building for the web, Emscripten automatically links a library that allows the program to communicate with the browser, but the headers need to be manually added through the
build.zig
. This PR updates theemcc.zig
compile function to automatically add the necessary headers for Emscripten before returning the step.The Emscripten functions can then be imported using the following snippet:
Unfortunately, I had to update the compile function to return an error because I couldn't think of a way to assemble the path without allocation.
Examples weren't affected. Tested on Windows 11.