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
This commit is contained in:
19
build.zig
19
build.zig
@@ -130,6 +130,18 @@ pub fn build(b: *std.Build) void {
|
|||||||
"uv/linux.h",
|
"uv/linux.h",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
.emscripten => {
|
||||||
|
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;");
|
||||||
|
root_module.addCSourceFiles(.{
|
||||||
|
.root = src_root,
|
||||||
|
.files = emscripten_sources,
|
||||||
|
.flags = cflags,
|
||||||
|
});
|
||||||
|
lib.installHeader(
|
||||||
|
include_root.path(b, "uv/posix.h"),
|
||||||
|
"uv/posix.h",
|
||||||
|
);
|
||||||
|
},
|
||||||
.haiku => {
|
.haiku => {
|
||||||
root_module.addCMacro("_BSD_SOURCE", "");
|
root_module.addCMacro("_BSD_SOURCE", "");
|
||||||
root_module.linkSystemLibrary("bsd", .{});
|
root_module.linkSystemLibrary("bsd", .{});
|
||||||
@@ -440,6 +452,13 @@ const solaris_sources: []const []const u8 = &.{
|
|||||||
"unix/sunos.c",
|
"unix/sunos.c",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const emscripten_sources: []const []const u8 = &.{
|
||||||
|
"unix/no-fsevents.c",
|
||||||
|
"unix/no-proctitle.c",
|
||||||
|
"unix/posix-hrtime.c",
|
||||||
|
"unix/posix-poll.c",
|
||||||
|
};
|
||||||
|
|
||||||
const haiku_sources: []const []const u8 = &.{
|
const haiku_sources: []const []const u8 = &.{
|
||||||
"unix/haiku.c",
|
"unix/haiku.c",
|
||||||
"unix/bsd-ifaddrs.c",
|
"unix/bsd-ifaddrs.c",
|
||||||
|
|||||||
Reference in New Issue
Block a user