Skip to content

[zig] Add run examples using zig and emscripten for web #5013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 1, 2025

Conversation

maiconpintoabreu
Copy link
Contributor

@maiconpintoabreu maiconpintoabreu commented Jun 29, 2025

This PR is to allow: zig build -Dtarget=wasm32-emscripten textures_sprite_anim

Changes:

  • if target.result.os.tag == .emscripten Steps are create as:
    • exe_lib - new
    • raylib - reused
    • ^ dependOn
    • emcc_command - new
    • ^ dependOn
    • run_step - new create by method emscriptenRunStep
  • Add const module_resources = b.pathJoin(&.{ module_subpath, "resources@resources" }); to be able to map resources folder for the examples.
  • Add run_step.addArg("--no_browser"); to run without running a browser so the user can point to the example manually.
  • Skipping rlgl_standalone and raylib_opengl_interop examples for now.

Result:
image

Now you can compile examples like:

  • zig build -Dtarget=wasm32-emscripten examples - it compiles all examples (except rlgl_standalone and raylib_opengl_interop for now)
  • zig build -Dtarget=wasm32-emscripten core - it compiles all examples for the especified module.
  • zig build -Dtarget=wasm32-emscripten textures_sprite_anim - it compiles a expecific example and serves it at default port 6931.

This PR has no impact on any binding as there is no change in method compileRaylib.

@maiconpintoabreu maiconpintoabreu marked this pull request as ready for review June 30, 2025 09:06
@raysan5 raysan5 merged commit 46f01e3 into raysan5:master Jul 1, 2025
2 checks passed
@raysan5
Copy link
Owner

raysan5 commented Jul 1, 2025

@maiconpintoabreu thanks for the update!

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.

2 participants