|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# Normal build |
| 5 | +# target/wasm32-unknown-emscripten/wasm/powersync.wasm |
| 6 | +RUSTFLAGS="-C link-arg=-sSIDE_MODULE=2" \ |
| 7 | + cargo build \ |
| 8 | + -p powersync_loadable \ |
| 9 | + --profile wasm \ |
| 10 | + --no-default-features \ |
| 11 | + --features "powersync_core/static powersync_core/omit_load_extension sqlite_nostd/omit_load_extension" \ |
| 12 | + -Z build-std=panic_abort,core,alloc \ |
| 13 | + --target wasm32-unknown-emscripten |
| 14 | + |
| 15 | +cp "target/wasm32-unknown-emscripten/wasm/powersync.wasm" "libpowersync.wasm" |
| 16 | + |
| 17 | +# Asyncify |
| 18 | +# target/wasm32-unknown-emscripten/wasm_asyncify/powersync.wasm |
| 19 | +RUSTFLAGS="-C link-arg=-sSIDE_MODULE=2 -C link-arg=-sASYNCIFY=1 -C link-arg=-sJSPI_IMPORTS=@wasm/asyncify_imports.json" \ |
| 20 | + cargo build \ |
| 21 | + -p powersync_loadable \ |
| 22 | + --profile wasm_asyncify \ |
| 23 | + --no-default-features \ |
| 24 | + --features "powersync_core/static powersync_core/omit_load_extension sqlite_nostd/omit_load_extension" \ |
| 25 | + -Z build-std=panic_abort,core,alloc \ |
| 26 | + --target wasm32-unknown-emscripten |
| 27 | + |
| 28 | +cp "target/wasm32-unknown-emscripten/wasm_asyncify/powersync.wasm" "libpowersync-async.wasm" |
| 29 | + |
| 30 | + |
| 31 | +# Static lib. |
| 32 | +# Works for both sync and asyncify builds. |
| 33 | +# Works for both emscripten and wasi. |
| 34 | +# target/wasm32-wasi/wasm/libpowersync.a |
| 35 | +cargo build \ |
| 36 | + -p powersync_loadable \ |
| 37 | + --profile wasm \ |
| 38 | + --no-default-features \ |
| 39 | + --features "powersync_core/static powersync_core/omit_load_extension sqlite_nostd/omit_load_extension" \ |
| 40 | + -Z build-std=panic_abort,core,alloc \ |
| 41 | + --target wasm32-wasi |
| 42 | + |
| 43 | +cp "target/wasm32-wasi/wasm/libpowersync.a" "libpowersync-wasm.a" |
0 commit comments