Replace just with cargo-run-wasm (#310)
This commit is contained in:
parent
a2c639823f
commit
9f7896cd2f
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[alias]
|
||||||
|
run-wasm = ["run", "--release", "--package", "run-wasm", "--"]
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -114,10 +114,8 @@ jobs:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
target: wasm32-unknown-unknown
|
target: wasm32-unknown-unknown
|
||||||
override: true
|
override: true
|
||||||
- name: Install tools
|
- name: WASM build
|
||||||
run: cargo install --locked wasm-bindgen-cli just
|
run: cargo run-wasm --build-only ${{ matrix.example }}
|
||||||
- name: Just build
|
|
||||||
run: just build ${{ matrix.example }}
|
|
||||||
|
|
||||||
# See https://github.com/parasyte/pixels-ci-rust-version
|
# See https://github.com/parasyte/pixels-ci-rust-version
|
||||||
rust-version:
|
rust-version:
|
||||||
|
|
|
@ -37,4 +37,5 @@ winit = "0.27"
|
||||||
members = [
|
members = [
|
||||||
"examples/*",
|
"examples/*",
|
||||||
"internals/*",
|
"internals/*",
|
||||||
|
"run-wasm",
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,11 +6,10 @@ Minimal example for WebGL2.
|
||||||
|
|
||||||
## Install build dependencies
|
## Install build dependencies
|
||||||
|
|
||||||
Install the WASM32 target and a few CLI tools:
|
Install the WASM32 target:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
rustup target add wasm32-unknown-unknown
|
rustup target add wasm32-unknown-unknown
|
||||||
cargo install --locked wasm-bindgen-cli just miniserve
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running on the Web
|
## Running on the Web
|
||||||
|
@ -18,18 +17,18 @@ cargo install --locked wasm-bindgen-cli just miniserve
|
||||||
Build the project and start a local server to host it:
|
Build the project and start a local server to host it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
just serve minimal-web
|
cargo run-wasm --release minimal-web
|
||||||
```
|
```
|
||||||
|
|
||||||
Open http://localhost:8080/ in your browser to run the example.
|
Open http://localhost:8000/ in your browser to run the example.
|
||||||
|
|
||||||
To build the project without serving it:
|
To build the project without serving it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
just build minimal-web
|
cargo run-wasm --release --build-only minimal-web
|
||||||
```
|
```
|
||||||
|
|
||||||
The build files are stored in `./target/minimal-web/`.
|
The build files are stored in `./target/wasm-examples/minimal-web/`.
|
||||||
|
|
||||||
## Running on native targets
|
## Running on native targets
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
background-color: #000;
|
|
||||||
margin: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<title>Hello Pixels + Web</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script type="module">
|
|
||||||
import init from "./minimal-web.js";
|
|
||||||
window.addEventListener("load", () => {
|
|
||||||
init();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
11
justfile
11
justfile
|
@ -1,11 +0,0 @@
|
||||||
serve package: (build package)
|
|
||||||
miniserve --index index.html ./target/{{package}}/
|
|
||||||
|
|
||||||
build package:
|
|
||||||
mkdir -p ./target/{{package}}/
|
|
||||||
cp ./examples/{{package}}/index.html ./target/{{package}}/
|
|
||||||
cargo build --release --package {{package}} --target wasm32-unknown-unknown
|
|
||||||
wasm-bindgen --target web --no-typescript --out-dir ./target/{{package}}/ ./target/wasm32-unknown-unknown/release/{{package}}.wasm
|
|
||||||
|
|
||||||
clean package:
|
|
||||||
rm -rf ./target/{{package}}/
|
|
8
run-wasm/Cargo.toml
Normal file
8
run-wasm/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "run-wasm"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies.cargo-run-wasm]
|
||||||
|
git = "https://github.com/rukai/cargo-run-wasm.git"
|
||||||
|
rev = "49d53e5eda86aaf66bfb271cb2e7e37cbcf4cfbb"
|
9
run-wasm/src/main.rs
Normal file
9
run-wasm/src/main.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fn main() {
|
||||||
|
let css = r#"body {
|
||||||
|
background-color: #000;
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}"#;
|
||||||
|
|
||||||
|
cargo_run_wasm::run_wasm_with_css(css);
|
||||||
|
}
|
Loading…
Reference in a new issue