#!/bin/bash # Build script for libghostty-vt WASM # Run this script after installing Zig set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" GHOSTTY_DIR="$SCRIPT_DIR/lib/ghostty" OUTPUT_DIR="$SCRIPT_DIR/src/frontend" echo "============================================" echo " Building libghostty-vt WebAssembly" echo "============================================" echo "" # Check Zig installation if ! command -v zig &> /dev/null; then echo "ERROR: Zig not found. Please install Zig 0.13.0+" echo "Download: https://ziglang.org/download/" exit 1 fi ZIG_VERSION=$(zig version) echo "Zig version: $ZIG_VERSION" echo "" # Create output directory mkdir -p "$OUTPUT_DIR" # Navigate to ghostty cd "$GHOSTTY_DIR" echo "Building libghostty-vt WASM..." echo "" # Build WASM module zig build lib-vt \ -Dtarget=wasm32-freestanding \ -Doptimize=ReleaseSmall \ -Dwasm_shared=false # Find and copy WASM output WASM_OUTPUT=$(find zig-out -name "*.wasm" 2>/dev/null | head -1) if [ -n "$WASM_OUTPUT" ]; then cp "$WASM_OUTPUT" "$OUTPUT_DIR/ghostty-vt.wasm" echo "" echo "============================================" echo " SUCCESS!" echo "============================================" echo "WASM file: $OUTPUT_DIR/ghostty-vt.wasm" echo "" echo "To run the terminal:" echo " cd ghostty-web && npm start" echo "" else echo "" echo "WARNING: WASM build succeeded but output not found" echo "Check: $GHOSTTY_DIR/zig-out/" fi