Skip to content

Add debug build option to build-wasm-example #19312

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 2 commits into from
May 24, 2025
Merged

Conversation

oracle58
Copy link
Contributor

Objective

Solution

  • Added --debug flag to build Wasm examples in debug mode.
  • Default remains release mode if --debug is not specified.
  • Updated documentation to describe the new flag and usage.

Testing

  • Verified debug and release builds for WebGL2 and WebGPU respectively.
  • Confirmed wasm artifacts are placed in the correct target dir for each build profile:
    • Debug: target/wasm32-unknown-unknown/debug/examples/
    • Release: target/wasm32-unknown-unknown/release/examples/
  • Confirmed wasm-bindgen output is written to: examples/wasm/target/debug , examples/wasm/target/release
  • Haven't actually tested running the example
Backend Profile Artifacts written Build success
webgl2 debug
webgl2 release
webpgu debug
webpgu release

Examples

Debug

$ cargo run -p build-wasm-example -- --api webgl2 --debug load_gltf
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1m 02s
wasm-bindgen --out-dir examples/wasm/target/debug --out-name wasm_example --target web target/wasm32-unknown-unknown/debug/examples/load_gltf.wasm

Release

$ cargo run -p build-wasm-example -- --api webgl2 load_gltf`
Finished `release` profile [optimized] target(s) in 1m 08s
wasm-bindgen --out-dir examples/wasm/target/release --out-name wasm_example --target web target/wasm32-unknown-unknown/release/examples/load_gltf.wasm

Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

- Add a  flag to tools/build-wasm-example to allow building wasm examples without release optimizations.
- Update examples/README.md to document how to use the new debug build option for WebGL2/WebGPU examples.
@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples O-Web Specific to web (WASM) builds C-Testing A change that impacts how we test Bevy or how users test their apps S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 22, 2025
@alice-i-cecile alice-i-cecile requested a review from rparrett May 22, 2025 01:32
- `index.html` and wasm-opt require bindings in `target` dir

Co-authored-by: Rob Parrett <robparrett@gmail.com>
@oracle58 oracle58 requested a review from rparrett May 23, 2025 05:04
@mockersf mockersf added this pull request to the merge queue May 24, 2025
Merged via the queue into bevyengine:main with commit d7cab93 May 24, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Examples An addition or correction to our examples C-Testing A change that impacts how we test Bevy or how users test their apps O-Web Specific to web (WASM) builds S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build-wasm-example should have an option for debug builds
4 participants