Add WebAssembly build support via Emscripten
- Cargo.toml: gate `wayland` feature behind cfg(not(wasm32)) so the dependency resolves correctly for both native and web targets - .cargo/config.toml: WASM linker flags (ASYNCIFY, GLFW, memory growth) - build_web.sh: sets required EMCC_CFLAGS, builds, copies artefacts to web/; accepts --serve to start a local HTTP server - web/index.html: minimal Emscripten shell with canvas and status line - .gitignore: exclude generated web/*.js and web/*.wasm artefacts - README: document web build prerequisites and usage ASYNCIFY lets the native while-loop main loop run unchanged in the browser. Build output: ~267 KB JS + ~458 KB WASM. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
11
README.md
11
README.md
@@ -40,6 +40,17 @@ cargo run
|
||||
cargo run --release
|
||||
```
|
||||
|
||||
**Web (WebAssembly)**
|
||||
|
||||
Prerequisites: [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) activated in your shell.
|
||||
|
||||
```sh
|
||||
./build_web.sh # produces web/*.js + web/*.wasm
|
||||
./build_web.sh --serve # build then serve at http://localhost:8080
|
||||
```
|
||||
|
||||
The web build uses ASYNCIFY so the main game loop requires no changes between native and browser targets.
|
||||
|
||||
**Tests**
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user