From 40a2a30f663e7f7a29aaa9a6199648d1e2f2467f Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 17 Dec 2024 15:04:40 -0800 Subject: [PATCH 1/3] Add ironfish-wasm build instructions Also ignores pkg directory. --- .gitignore | 3 +++ ironfish-rust-wasm/README.md | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 ironfish-rust-wasm/README.md diff --git a/.gitignore b/.gitignore index 0a5751c5b2..697e03b03f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ testdbs # production **/build +# rust wasm +**/pkg + # misc .DS_Store .env diff --git a/ironfish-rust-wasm/README.md b/ironfish-rust-wasm/README.md new file mode 100644 index 0000000000..23fa2fc51a --- /dev/null +++ b/ironfish-rust-wasm/README.md @@ -0,0 +1,25 @@ +# Ironfish Rust WASM + +This is a WASM build of the Ironfish Rust library. + +## Building on Linux + +```bash +wasm-pack build --target web --release +``` + +## Building on Mac + +```bash +AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang cargo build --release --target wasm32-unknown-unknown +``` + +```bash +wasm-bindgen ../target/wasm32-unknown-unknown/release/ironfish_wasm.wasm --out-dir ./pkg +``` + +Install `wasm-bindgen` + +```bash +cargo install -f wasm-bindgen-cli --version 0.2.95 +``` From 12d18f58aa6d1e7e070aa48131afa4a319a49e76 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 17 Dec 2024 16:40:03 -0800 Subject: [PATCH 2/3] updates readme with wasmpack instructions --- ironfish-rust-wasm/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ironfish-rust-wasm/README.md b/ironfish-rust-wasm/README.md index 23fa2fc51a..10f4310cd6 100644 --- a/ironfish-rust-wasm/README.md +++ b/ironfish-rust-wasm/README.md @@ -10,6 +10,16 @@ wasm-pack build --target web --release ## Building on Mac +### Using `wasm-pack` + +```bash +AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang wasm-pack build --release --target web +``` + +### Using `cargo` and `wasm-bindgen` + +In case building with `wasm-pack` fails, you can try building with `cargo` and `wasm-bindgen`: + ```bash AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang cargo build --release --target wasm32-unknown-unknown ``` From f9a3508ccad50d95d98078d835bcc016352fa4a2 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 17 Dec 2024 16:41:42 -0800 Subject: [PATCH 3/3] adds reference --- ironfish-rust-wasm/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ironfish-rust-wasm/README.md b/ironfish-rust-wasm/README.md index 10f4310cd6..8f0f23f9b2 100644 --- a/ironfish-rust-wasm/README.md +++ b/ironfish-rust-wasm/README.md @@ -12,6 +12,8 @@ wasm-pack build --target web --release ### Using `wasm-pack` +Reference: https://mikeder.net/blog/m1-mac-wasm/ + ```bash AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang wasm-pack build --release --target web ```