Skip to content
/ mq-wbg-template Public template

A template repo for building macroquad via wasm-bindgen, including convenience crates.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

GhtGhoster/mq-wbg-template

Repository files navigation

Macroquad wasm-bindgen build template with support for GitHub Pages

This repository serves as a template for projects based on the Rust macroquad crate, built with the wasm-bindgen command line utility. Included are rand, getrandom, egui, and egui-macroquad crates for future convenience. Its intention is making WASM building, WASM bindings generation, and readying the repository for GitHub Pages as painless as possible.

(2 "required" .js files from egui-macroquad -> quad-url omitted because nothing broke so far)

More interesting crates to look out for in the future:

Instructions and dependencies:

All scripts listed below are compatible with default Windows installation of PowerShell (v6+ not required) as well as bash for Linux (scripts are polyglot)

This script changes the internal name of the project in the files src\main.rs, Cargo.toml, and index.html to match the name of the repository, and allows cargo to work correctly.

(This is only necessary to run once after a repository was first created with the mq-wbg-template template.)

(todo: auto-remove rename script and README.md section after readme.ps1)

This script installs wasm-bindgen-cli (version 0.2.84), basic-http-server and adds wasm32-unknown-unknown to possible compilation targets. Note that this version of wasm-bindgen-cli is required for the pipeline defined in this repository.

On linux, this script also installs libssl-dev and libasound2-dev, which are required for basic-http-server and macroquad to run respectively.

(This is only necessary to run once on a single computer as the effects of this script are global.)

This script builds the project for the wasm32-unknown-unknown target in --release mode, generates WASM bindings, and patches the generated JavaScript file. It also moves the relevant files to their appropriate directories in preparation for running the project on a local server or on GitHub Pages.

This script hosts the built project on a local basic-http-server server and opens a browser at its location.

(One does not need to restart the server after building the project again, reloading the webpage in the browser is sufficent.)

(This is necessary over just opening the index.html file in your browser so that the required resources load properly.)

Sources:

JS patching scripts:

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A template repo for building macroquad via wasm-bindgen, including convenience crates.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published