-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-wasm.sh
More file actions
53 lines (44 loc) · 1.46 KB
/
Copy pathbuild-wasm.sh
File metadata and controls
53 lines (44 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Build script for nomos-healer-guest WASM module
#
# Prerequisites:
# rustup target add wasm32-wasip1
#
# Output:
# target/wasm32-wasip1/release/nomos_healer_guest.wasm
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Building WASM healer guest..."
# Build the WASM module
cargo build \
--package nomos-healer-guest \
--target wasm32-wasip1 \
--release
# Get the output path
WASM_PATH="target/wasm32-wasip1/release/nomos_healer_guest.wasm"
if [ -f "$WASM_PATH" ]; then
SIZE=$(stat --printf="%s" "$WASM_PATH" 2>/dev/null || stat -f %z "$WASM_PATH")
SIZE_KB=$(echo "scale=2; $SIZE / 1024" | bc)
echo ""
echo "✓ Built successfully: $WASM_PATH"
echo " Size: ${SIZE_KB} KB"
# Check against 500KB target
if [ "$SIZE" -gt 512000 ]; then
echo " ⚠ WARNING: Exceeds 500KB target!"
else
echo " ✓ Under 500KB target"
fi
# Optional: Run wasm-opt for further size reduction
if command -v wasm-opt &> /dev/null; then
echo ""
echo "Running wasm-opt for size optimization..."
wasm-opt -Oz "$WASM_PATH" -o "${WASM_PATH%.wasm}.opt.wasm"
OPT_SIZE=$(stat --printf="%s" "${WASM_PATH%.wasm}.opt.wasm" 2>/dev/null || stat -f %z "${WASM_PATH%.wasm}.opt.wasm")
OPT_SIZE_KB=$(echo "scale=2; $OPT_SIZE / 1024" | bc)
echo " Optimized size: ${OPT_SIZE_KB} KB"
fi
else
echo "✗ Build failed!"
exit 1
fi