Setup emscripten (#782)

This commit is contained in:
Ross Savage
2025-03-24 06:21:58 +01:00
committed by GitHub
parent 3ad0cabc72
commit fb232f0707
4 changed files with 57 additions and 1 deletions

View File

@@ -79,6 +79,9 @@ jobs:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
- name: Clippy
run: make wasm-clippy
@@ -143,6 +146,9 @@ jobs:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
- name: Cargo build
working-directory: lib/wasm
run: cargo build --target=wasm32-unknown-unknown
@@ -295,6 +301,9 @@ jobs:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
- name: Test WASM
run: make wasm-test

View File

@@ -34,7 +34,11 @@ __*[lib/bindings](lib/bindings)*__
__*[lib/core](lib/core)*__
* [bindings.rs](lib/core/src/bindings.rs) - Update the Rust interface for the Flutter Rust Bridge bindings.
After making these changes the [Dart](packages/dart), [Flutter](packages/flutter) and [React Native](packages/react-native) bindings code also need to be regenerated and included in your pull request. You can regenerate these from the project root using `make codegen`. Please see the prerequisites for [Flutter](lib/bindings/langs/flutter/README.md) and [React Native](packages/react-native/DEVELOPING.md) if this is your first time generating code.
__*[lib/wasm](lib/wasm)*__
* [model.rs](lib/wasm/src/model.rs) - Update the structs/enums exported.
* [lib.rs](lib/wasm/src/lib.rs) - Update the Rust interface for the WASM bindings.
After making these changes the [Dart](packages/dart), [Flutter](packages/flutter) and [React Native](packages/react-native) bindings code also need to be regenerated and included in your pull request. You can regenerate these from the project root using `make codegen`. Please see the prerequisites for [Flutter](lib/bindings/langs/flutter/README.md), [React Native](packages/react-native/DEVELOPING.md) and [WASM](lib/wasm/DEVELOPING.md) if this is your first time generating code.
#### Testing
Please adequately test your code using the existing tests and write additional tests for new features. You can run the tests from the project root using `make test`. You can also make use of the [CLI](cli) to test changes while developing your feature.

10
lib/Cargo.lock generated
View File

@@ -5974,6 +5974,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webpki"
version = "0.22.4"

33
lib/wasm/DEVELOPING.md Normal file
View File

@@ -0,0 +1,33 @@
# Building WASM
## Prerequisites
To build some dependencies you need to first install [emscripten](https://emscripten.org/docs/getting_started/downloads.html):
```bash
brew install emscripten
```
On first usage you will need to run:
```bash
make init
```
## Building
```bash
make pack
```
This will generate the following artifacts:
- `pkg/package.json`
- `pkg/breez_sdk_liquid_wasm_bg.wasm`
- `pkg/breez_sdk_liquid_wasm_bg.d.wasm`
- `pkg/breez_sdk_liquid_wasm.d.ts`
- `pkg/breez_sdk_liquid_wasm.js`
## Testing
```bash
make test
```