Created
February 1, 2017 15:46
-
-
Save BookOwl/431ba90831b21cf0eef98d6cce97714d to your computer and use it in GitHub Desktop.
A bash script to get Rust ready to compile to the web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First we get Rust ready. | |
echo "Getting Rust ready..." | |
rustup default nightly | |
rustup target add asmjs-unknown-emscripten | |
rustup target add wasm32-unknown-emscripten | |
# Now we get emscripten | |
echo "Rust is ready. Installing Emscripten..." | |
curl -O https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | |
tar -xzf emsdk-portable.tar.gz | |
source emsdk_portable/emsdk_env.sh | |
emsdk update | |
emsdk install sdk-incoming-64bit | |
emsdk activate sdk-incoming-64bit | |
# Get emscripten's cache ready. This will make build times much faster | |
echo 'fn main() { println!("Hello, Emscripten!"); }' > hello.rs | |
rustc --target=asmjs-unknown-emscripten hello.rs | |
rustc --target=wasm32-unknown-emscripten hello.rs | |
echo "Emscripten installed" | |
# Clean up | |
rm hello.js emsdk-portable.tar.gz hello.rs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based off of https://users.rust-lang.org/t/compiling-to-the-web-with-rust-and-emscripten/7627