Skip to content

Commit 865e6ef

Browse files
committed
add xtask command to build - needs cargo 1.91.0
rust-lang/cargo#15838
1 parent 964476c commit 865e6ef

File tree

7 files changed

+261
-25
lines changed

7 files changed

+261
-25
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", "examples/simple"]
2+
members = ["xtask", "examples/simple", "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

rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
22
channel = "stable"
3-
targets = [ "wasm32-unknown-unknown" ]
4-
3+
targets = ["wasm32-unknown-unknown"]
4+
components = ["rust-analyzer", "clippy"]

xtask/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "xtask"
3+
version.workspace = true
4+
edition.workspace = true
5+
6+
[dependencies]
7+
anyhow = "1.0.99"
8+
clap = { version = "4.5.46", features = ["derive"] }
9+
xshell = "0.2.7"

0 commit comments

Comments
 (0)