64 lines
2.2 KiB
PowerShell
64 lines
2.2 KiB
PowerShell
# Build script for libghostty-vt WASM (PowerShell)
|
|
# Run this script after installing Zig
|
|
|
|
param(
|
|
[string]$OutputDir = "src\frontend"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "============================================" -ForegroundColor Cyan
|
|
Write-Host " Building libghostty-vt WebAssembly" -ForegroundColor Cyan
|
|
Write-Host "============================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Check Zig installation
|
|
$zig = Get-Command zig -ErrorAction SilentlyContinue
|
|
if (-not $zig) {
|
|
Write-Host "ERROR: Zig not found. Please install Zig 0.13.0+" -ForegroundColor Red
|
|
Write-Host "Download: https://ziglang.org/download/" -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
|
|
$zigVersion = zig version
|
|
Write-Host "Zig version: $zigVersion"
|
|
Write-Host ""
|
|
|
|
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
if (-not $SCRIPT_DIR) { $SCRIPT_DIR = Get-Location }
|
|
$GHOSTTY_DIR = Join-Path $SCRIPT_DIR "lib\ghostty"
|
|
$OUTPUT_DIR = Join-Path $SCRIPT_DIR $OutputDir
|
|
|
|
# Create output directory
|
|
New-Item -ItemType Directory -Force -Path $OUTPUT_DIR | Out-Null
|
|
|
|
# Navigate to ghostty
|
|
Set-Location $GHOSTTY_DIR
|
|
|
|
Write-Host "Building libghostty-vt WASM..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# Build WASM module
|
|
zig build lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall -Dwasm_shared=false
|
|
|
|
# Find and copy WASM output
|
|
$wasmFiles = Get-ChildItem -Path "zig-out" -Recurse -Filter "*.wasm" -ErrorAction SilentlyContinue
|
|
|
|
if ($wasmFiles) {
|
|
$wasmOutput = $wasmFiles[0].FullName
|
|
Copy-Item $wasmOutput (Join-Path $OUTPUT_DIR "ghostty-vt.wasm") -Force
|
|
|
|
Write-Host ""
|
|
Write-Host "============================================" -ForegroundColor Green
|
|
Write-Host " SUCCESS!" -ForegroundColor Green
|
|
Write-Host "============================================" -ForegroundColor Green
|
|
Write-Host "WASM file: $(Join-Path $OUTPUT_DIR 'ghostty-vt.wasm')"
|
|
Write-Host ""
|
|
Write-Host "To run the terminal:" -ForegroundColor Cyan
|
|
Write-Host " cd ghostty-web; npm start" -ForegroundColor White
|
|
Write-Host ""
|
|
} else {
|
|
Write-Host ""
|
|
Write-Host "WARNING: WASM build succeeded but output not found" -ForegroundColor Yellow
|
|
Write-Host "Check: $GHOSTTY_DIR\zig-out\" -ForegroundColor Yellow
|
|
} |