-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathbuild-wasm.sh
More file actions
executable file
·56 lines (47 loc) · 1.4 KB
/
build-wasm.sh
File metadata and controls
executable file
·56 lines (47 loc) · 1.4 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
#!/bin/bash
set -euo pipefail
echo "🔨 Building ghostty-vt.wasm..."
# Check for Zig
if ! command -v zig &> /dev/null; then
echo "❌ Error: Zig not found"
echo ""
echo "Install Zig 0.15.2+:"
echo " macOS: brew install zig"
echo " Linux: https://ziglang.org/download/"
echo ""
exit 1
fi
ZIG_VERSION=$(zig version)
echo "✓ Found Zig $ZIG_VERSION"
# Initialize/update submodule
if [ ! -d "ghostty/.git" ]; then
echo "📦 Initializing Ghostty submodule..."
git submodule update --init --recursive
else
echo "📦 Ghostty submodule already initialized"
fi
# Apply patch
echo "🔧 Applying WASM API patch..."
cd ghostty
git apply --check ../patches/ghostty-wasm-api.patch || {
echo "❌ Patch doesn't apply cleanly"
echo "Ghostty may have changed. Check patches/ghostty-wasm-api.patch"
exit 1
}
git apply ../patches/ghostty-wasm-api.patch
# Build WASM
echo "⚙️ Building WASM (takes ~20 seconds)..."
zig build lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall
# Copy to project root
cd ..
cp ghostty/zig-out/bin/ghostty-vt.wasm ./
# Revert patch to keep submodule clean
echo "🧹 Cleaning up..."
cd ghostty
git apply -R ../patches/ghostty-wasm-api.patch
# Remove new files created by the patch
rm -f include/ghostty/vt/terminal.h
rm -f src/terminal/c/terminal.zig
cd ..
SIZE=$(du -h ghostty-vt.wasm | cut -f1)
echo "✅ Built ghostty-vt.wasm ($SIZE)"