Skip to content

Commit e4dc0dd

Browse files
Rawan10101torque
authored andcommitted
build: add Emscripten/WASM support
The wasm build requires the Emscripten SDK to be available. Then the library can be built with something like: zig build -Dtarget=wasm32-emscripten --search-prefix $EMSDK/upstream/emscripten/cache/sysroot
1 parent dd606c7 commit e4dc0dd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

build.zig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ pub fn build(b: *std.Build) void {
130130
"uv/linux.h",
131131
);
132132
},
133+
.emscripten => {
134+
root_module.addCMacro("UV_PLATFORM_LOOP_FIELDS", "struct pollfd* poll_fds; size_t poll_fds_used; size_t poll_fds_size; unsigned char poll_fds_iterating;");
135+
root_module.addCSourceFiles(.{
136+
.root = src_root,
137+
.files = emscripten_sources,
138+
.flags = cflags,
139+
});
140+
lib.installHeader(
141+
include_root.path(b, "uv/posix.h"),
142+
"uv/posix.h",
143+
);
144+
},
133145
.haiku => {
134146
root_module.addCMacro("_BSD_SOURCE", "");
135147
root_module.linkSystemLibrary("bsd", .{});
@@ -440,6 +452,13 @@ const solaris_sources: []const []const u8 = &.{
440452
"unix/sunos.c",
441453
};
442454

455+
const emscripten_sources: []const []const u8 = &.{
456+
"unix/no-fsevents.c",
457+
"unix/no-proctitle.c",
458+
"unix/posix-hrtime.c",
459+
"unix/posix-poll.c",
460+
};
461+
443462
const haiku_sources: []const []const u8 = &.{
444463
"unix/haiku.c",
445464
"unix/bsd-ifaddrs.c",

0 commit comments

Comments
 (0)