Skip to content

Instantly share code, notes, and snippets.

@BookOwl
Created February 1, 2017 15:46
Show Gist options
  • Save BookOwl/431ba90831b21cf0eef98d6cce97714d to your computer and use it in GitHub Desktop.
Save BookOwl/431ba90831b21cf0eef98d6cce97714d to your computer and use it in GitHub Desktop.
A bash script to get Rust ready to compile to the web
# 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
@BookOwl
Copy link
Author

BookOwl commented Feb 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment