I am learning Rust+Wasm and wanted to set up a way to build three outputs on my Mac from the same Cargo file:
- Wasm client
- Mac server
- Linux server
I don’t think this is the best way to do it but I am sharing what I did.
brew install rustup
rustup-init
# add $HOME/.cargo/bin to $PATH
rustup target add rust-src
cargo install --version 2.0.13 racer
Install the Web Assembly tools:
rustup target add wasm32-unknown-unknown
brew install wabt binaryen
cargo install wasm-snip
cargo install wasm-gc
cargo install wasm-bindgen-cli
Install the Linux cross compiler:
rustup target add x86_64-unknown-linux-musl
brew install FiloSottile/musl-cross/musl-cross
To make the cross-compiler work, the project’s .cargo/config
should contain:
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
Build the code:
make
Run the server:
make run-server
Then load build/embed.html
into your browser.