1
0
Fork
You've already forked emsdkz
0
Emscripten SDK integration for Zig projects.
  • Zig 100%
2026年06月26日 10:32:51 -07:00
.gitignore Initial import. 2026年03月09日 09:05:06 -07:00
build.zig Fix issue. 2026年06月26日 10:32:51 -07:00
build.zig.zon Update fingerprint. 2026年04月26日 10:06:23 -07:00
LICENSE-APACHE Initial import. 2026年03月09日 09:05:06 -07:00
LICENSE-MIT Initial import. 2026年03月09日 09:05:06 -07:00
README.md Add basic README. 2026年03月09日 11:21:51 -07:00

EMSDKZ

EMSDKZ is a build library for Zig to support Emscripten builds. It allows for common usage, such as building executables, linking ports, and configuring header file locations.

Getting Started

On the command line:

zig fetch --save=emsdkz git+https://codeberg.org/scriblz/emsdkz

In build.zig

constemsdkz=@import("emsdkz");constEmSdk=emsdkz.EmSdk;pubfnbuild(b:*std.Build)void{constmaybe_emsdk=switch(target.result.os.tag){.emscripten=>EmSdk.create(b,emsdkz_dep,.{}),else=>null,};constexe_mod=b.createModule(...);switch(target.result.os.tag){.emscripten=>{constexe=b.addLibrary(.{.name="example",.root_module=exe_mod,});if(maybe_emsdk)|emsdk|{constlink_step=emsdk.addLinkStep(.{.main=exe,.target=target,.optimize=optimize,.ports=&.{"emdawnwebgpu","contrib.glfw3",// other required ports},// path to the shell file used to run the project.shell_file_path=b.path("shell.html"),});construn=emsdk.addRunStep(.{.name="example",// optional browser param to override which browser to run with.browser="chrome",});run.step.dependOn(&link_step.step);if(optimize==.Debug){// install src files for debugging in browserconstinstall_src_dir=b.addInstallDirectory(.{.source_dir=b.path("src"),.install_dir=.{.custom="web"},.install_subdir="src",});run.step.dependOn(&install_src_dir.step);}b.step("example","Run example").dependOn(&run.step);}},else=>{// do normal build things},}}

Building Ports

pubfnbuild(b:*std.Build)void{...if(maybe_emsdk)|emsdk|{constbuild_dawn_port_step=emsdk.addBuildPort(.{.port_name="emdawnwebgpu",});constwebgpu_include_path=emsdk.portPath("emdawnwebgpu",&.{"emdawnwebgpu_pkg","webgpu","include"});my_module.addSystemIncludePath(webgpu_include_path);}}