forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·62 lines (50 loc) · 1.7 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·62 lines (50 loc) · 1.7 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
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Build the Soroban contract to WASM
#
# I designed this script to be run from any directory.
# It handles the build process and optional optimization.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CONTRACT_DIR="$SCRIPT_DIR/../split-escrow"
TARGET_DIR="$SCRIPT_DIR/../target"
echo "🔨 Building split-escrow contract..."
echo " Contract directory: $CONTRACT_DIR"
cd "$CONTRACT_DIR"
# Check if wasm32 target is installed
if ! rustup target list --installed | grep -q wasm32-unknown-unknown; then
echo "📦 Installing wasm32-unknown-unknown target..."
rustup target add wasm32-unknown-unknown
fi
# Build for release
echo "🔧 Compiling contract..."
cargo build --target wasm32-unknown-unknown --release
WASM_PATH="$CONTRACT_DIR/target/wasm32-unknown-unknown/release/split_escrow.wasm"
# Check if build succeeded
if [ -f "$WASM_PATH" ]; then
echo "✅ Build successful!"
echo "📁 Output: $WASM_PATH"
# Show file size
SIZE=$(ls -lh "$WASM_PATH" | awk '{print $5}')
echo "📊 Contract size: $SIZE"
else
echo "❌ Build failed: WASM file not found"
exit 1
fi
# Optimize WASM if soroban CLI is available
if command -v soroban &> /dev/null; then
echo ""
echo "📦 Optimizing WASM with Soroban CLI..."
soroban contract optimize --wasm "$WASM_PATH"
OPTIMIZED_PATH="${WASM_PATH%.wasm}.optimized.wasm"
if [ -f "$OPTIMIZED_PATH" ]; then
OPT_SIZE=$(ls -lh "$OPTIMIZED_PATH" | awk '{print $5}')
echo "✅ Optimization complete!"
echo "📊 Optimized size: $OPT_SIZE"
fi
else
echo ""
echo "💡 Tip: Install soroban-cli for WASM optimization:"
echo " cargo install soroban-cli"
fi
echo ""
echo "🎉 Build complete!"