To build WASM binary from source, the following prerequisites are required:
- Install
wasm-pack
cargo install wasm-pack
- OSX specific: install
llvm
brew install llvm
To build WASM release binary run one of the following commands according to your environment:
- for Linux users:
wasm-pack build mm2src/mm2_bin_lib --target web --out-dir wasm_build/deps/pkg/
- for OSX users (Intel):
CC=/usr/local/opt/llvm/bin/clang AR=/usr/local/opt/llvm/bin/llvm-ar wasm-pack build mm2src/mm2_bin_lib --target web --out-dir wasm_build/deps/pkg/
- for OSX users (Apple Silicon):
CC=/opt/homebrew/opt/llvm/bin/clang AR=/opt/homebrew/opt/llvm/bin/llvm-ar wasm-pack build mm2src/mm2_bin_lib --target web --out-dir wasm_build/deps/pkg/
Please note CC
and AR
must be specified in the same line as wasm-pack test mm2src/mm2_main
.
If you want to disable optimizations to reduce the compilation time, run wasm-pack build mm2src/mm2_bin_lib
with an additional --dev
flag:
wasm-pack build mm2src/mm2_bin_lib --target web --out-dir wasm_build/deps/pkg/ --dev
Please don't forget to specify CC
and AR
if you run the command on OSX.