Skip to content

Conversation

@barathrm
Copy link

@barathrm barathrm commented Dec 20, 2025

Hi all!

I have this fork / branch that I've been using of zemscripten for my own projects where I attempted to

  • ensure that the activate/install commands don't run every time I run zig build
  • they're not run unnecessarily when building with zig build --watch
  • don't use the emsdk from the global (~/.config/zig) cache directory, but instead let every zig package which depends on the emsdk have its own instance in the project-specific cache directory (.zig-cache)
  • don't hardcode versions
  • only use LazyPaths, since the emsdk script is not really a system command but rather something orchestrated by zig

I see that main recently got some stuff pushed, and there are merge conflicts, but I mainly wanted to start a discussion around the best way of handling caching and integration of the emsd into the watch mechanic and package manager in general. I'd fix up this PR if the flow it sketches out is something that makes sense for zemscripten.

Let me know what you think or if you have any ideas! And thanks for starting zemscripten, it helped a lot when I needed to figure out how to integrate emscripten with zig 🙏


Only use LazyPaths to improve caching and rebuild triggering. To achieve this, don't use addSystemCommand. Instead we have to build small zig programs to act as runArtifacts which allow us to rely on dynamic input and output paths only. Tell me if you know a better way!

Install SDKs into project-specific cache directory which should allow different projects using different emsdk versions more easily on the same build host.

Recursively add a build target's dependencies to the emcc command.

@barathrm barathrm force-pushed the barath/cache-friendliness branch from 532f4ab to 77b3cd6 Compare December 20, 2025 10:21
Only use LazyPaths to improve caching and rebuild triggering. To achieve
this, don't use addSystemCommand. Instead we have to build small zig
programs to act as runArtifacts which allow us to rely on dynamic input
and output paths only. Tell me if you know a better way!

Install SDKs into project-specific cache directory which should allow
different projects using different emsdk versions more easily on the
same build host.

Recursively add a build target's dependencies to the emcc command.
@barathrm barathrm force-pushed the barath/cache-friendliness branch from 77b3cd6 to fe93878 Compare December 20, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant