diff --git a/docs-template/EXAMPLE_README.md.tpl b/docs-template/EXAMPLE_README.md.tpl index a5438464b3..9cde78c3b9 100644 --- a/docs-template/EXAMPLE_README.md.tpl +++ b/docs-template/EXAMPLE_README.md.tpl @@ -269,6 +269,7 @@ Bevy has a helper to build its examples: - Build for WebGL2: `cargo run -p build-wasm-example -- --api webgl2 load_gltf` - Build for WebGPU: `cargo run -p build-wasm-example -- --api webgpu load_gltf` +- Debug: `cargo run -p build-wasm-example -- --debug --api webgl2 load_gltf` This helper will log the command used to build the examples. diff --git a/examples/README.md b/examples/README.md index a4ff3474dd..377d8ecc0a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -782,6 +782,7 @@ Bevy has a helper to build its examples: - Build for WebGL2: `cargo run -p build-wasm-example -- --api webgl2 load_gltf` - Build for WebGPU: `cargo run -p build-wasm-example -- --api webgpu load_gltf` +- Debug: `cargo run -p build-wasm-example -- --debug --api webgl2 load_gltf` This helper will log the command used to build the examples. diff --git a/tools/build-wasm-example/src/main.rs b/tools/build-wasm-example/src/main.rs index 1162aaece7..25c0b07152 100644 --- a/tools/build-wasm-example/src/main.rs +++ b/tools/build-wasm-example/src/main.rs @@ -39,6 +39,10 @@ struct Args { #[arg(long)] /// Additional features to enable features: Vec, + + #[arg(long)] + /// Build the example in debug mode instead of release + debug: bool, } fn main() { @@ -73,15 +77,23 @@ fn main() { parameters.push("--features"); parameters.push(&features_string); } + + let profile = if cli.debug { + "debug" + } else { + parameters.push("--release"); + "release" + }; + let cmd = cmd!( sh, - "cargo build {parameters...} --profile release --target wasm32-unknown-unknown --example {example}" + "cargo build {parameters...} --target wasm32-unknown-unknown --example {example}" ); cmd.run().expect("Error building example"); cmd!( sh, - "wasm-bindgen --out-dir examples/wasm/target --out-name wasm_example --target web target/wasm32-unknown-unknown/release/examples/{example}.wasm" + "wasm-bindgen --out-dir examples/wasm/target --out-name wasm_example --target web target/wasm32-unknown-unknown/{profile}/examples/{example}.wasm" ) .run() .expect("Error creating wasm binding");