Rust gdext
wasm test project
(Full info at https://gist.github.com/PgBiel/ffa695a479ef4466cb24755db983950b)
- Ensure you have nightly cargo installed through
rustup
- E.g.
rustup toolchain install nightly
- Add the following to
~/.cargo/config.toml
:
rustflags = [
"-C", "target-feature=+atomics,+bulk-memory,+mutable-globals",
]
[unstable]
build-std = ["panic_abort", "std"]
The above will ensure the Rust standard library will be buit whenever using a nightly toolchain. This is necessary to use the flags listed above while compiling the standard library.
- Ensure you have emsdk v3.1.45
- If you don't have it, you may follow these steps:
- Go to a directory where to install it
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 3.1.45
./emsdk activate 3.1.45
source ./emsdk_env.sh
- Confirm with
emcc --version
- Come back to this project's root folder with
cd
, and runcd rust
- Run
cargo +nightly build --target wasm32-unknown-emscripten
to build the Rust code
- Note: cargo may ask you to run a rustup command to fetch the Rust standard library's source code.
If prompted with a suggested
rustup
command, make sure to run it.
- You can now open the
godot/
folder in the Godot editor and attempt to export to the web.