Skip to content

Commit 8520461

Browse files
committed
add xtask command to build - needs cargo 1.91.0
rust-lang/cargo#15838
1 parent e6fb440 commit 8520461

File tree

9 files changed

+265
-29
lines changed

9 files changed

+265
-29
lines changed

.cargo/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
[build]
22
target = "wasm32-unknown-unknown"
3+
4+
[alias]
5+
# XXX requires https://github.com/rust-lang/cargo/pull/15838
6+
xtask = "run --target host --manifest-path ./xtask/Cargo.toml --"

Cargo.lock

Lines changed: 178 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["examples/cubes"]
2+
members = ["xtask", "examples/cubes"]
33

44
[workspace.package]
55
version = "0.2.0"

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ See [examples/cubes/src/lib.rs](examples/cubes/src/lib.rs) for example use.
77

88
To run the demo locally:
99
```sh-session
10-
$ cargo install wasm-pack
11-
$ wasm-pack build --target web examples/cubes --features webgpu
10+
$ cargo install wasm-opt wasm-bindgen-cli
11+
$ cargo build --profile debug --target wasm32-unknown-unknown --example cubes
12+
$ wasm-bindgen --out-dir examples/wasm/target --out-name wasm_example --target web target/wasm32-unknown-unknown/debug/examples/{example}.wasm
13+
$ wasm-opt -Oz --output examples/wasm/target/wasm_example_bg.wasm.optimized examples/wasm/target/wasm_example_bg.wasm
14+
# rename wasm.optimized
1215
$ python3 -m http.server -d examples/cubes # now open http://localhost:8000/
1316
```
17+
XXX see https://github.com/bevyengine/bevy/blob/6608d9815da46e1c79ec3887568a068e63065f49/tools/build-wasm-example/src/main.rs

examples/cubes/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Bevy Web Video</title>
77
<script type="module">
8-
import init, { start } from "./pkg/cubes.js";
8+
import init from "./pkg/cubes.js";
99
await init();
10-
start();
1110
</script>
1211
</head>
1312
<body></body>

0 commit comments

Comments
 (0)