Skip to content

Commit

Permalink
Replace just with cargo-run-wasm (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte authored Oct 3, 2022
1 parent a2c6398 commit 9f7896c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
run-wasm = ["run", "--release", "--package", "run-wasm", "--"]
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ jobs:
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Install tools
run: cargo install --locked wasm-bindgen-cli just
- name: Just build
run: just build ${{ matrix.example }}
- name: WASM build
run: cargo run-wasm --build-only ${{ matrix.example }}

# See https://github.com/parasyte/pixels-ci-rust-version
rust-version:
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ winit = "0.27"
members = [
"examples/*",
"internals/*",
"run-wasm",
]
11 changes: 5 additions & 6 deletions examples/minimal-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@ Minimal example for WebGL2.

## Install build dependencies

Install the WASM32 target and a few CLI tools:
Install the WASM32 target:

```bash
rustup target add wasm32-unknown-unknown
cargo install --locked wasm-bindgen-cli just miniserve
```

## Running on the Web

Build the project and start a local server to host it:

```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:

```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

Expand Down
24 changes: 0 additions & 24 deletions examples/minimal-web/index.html

This file was deleted.

11 changes: 0 additions & 11 deletions justfile

This file was deleted.

8 changes: 8 additions & 0 deletions run-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions run-wasm/src/main.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 9f7896c

Please sign in to comment.