AtlatestRepositorysigil-http
sigil-http / treecompile.sh
1
#!/usr/bin/env bash2
# Compile sigil-http library modules to ./lib for testing3
# Usage: ./compile.sh5
set -e7
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"8
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"10
# sgl-boot must run from project root to find stdlib/prelude.sgl11
cd "$PROJECT_ROOT"13
SGL_BOOT="./build/bin/sgl-boot"14
if [ ! -x "$SGL_BOOT" ]; then15
echo "Error: sgl-boot not found at $SGL_BOOT. Build sigil first."16
exit 117
fi19
echo "Using: $SGL_BOOT (from $PROJECT_ROOT)"21
BUILD_LIB="./build/lib"22
if [ ! -d "$BUILD_LIB" ]; then23
echo "Error: build/lib not found. Build sigil first."24
exit 125
fi27
PKG_DIR="packages/sigil-http"29
# Create output directories30
mkdir -p "$PKG_DIR/lib/sigil/http"32
# Compile library modules33
echo "Compiling library modules..."34
for f in src/sigil/http/mime.sgl \35
src/sigil/http/request.sgl \36
src/sigil/http/response.sgl \37
src/sigil/http/server.sgl \38
src/sigil/http.sgl; do39
src="$PKG_DIR/$f"40
if [ -f "$src" ]; then41
out="$PKG_DIR/lib/$(echo "$f" | sed 's|^src/||; s|\.sgl$|.sgb|')"42
mkdir -p "$(dirname "$out")"43
echo " $f -> $out"44
"$SGL_BOOT" -L "$BUILD_LIB" -L "$PKG_DIR/lib" --compile "$src" "$out" 2>&1 | grep -v "^Error: syntax-rules" || true45
fi46
done48
# Compile test files49
echo "Compiling tests..."50
mkdir -p "$PKG_DIR/lib/test"51
for f in "$PKG_DIR"/test/*.sgl; do52
if [ -f "$f" ]; then53
base="$(basename "$f" .sgl)"54
out="$PKG_DIR/lib/test/$base.sgb"55
echo " test/$base.sgl -> $out"56
"$SGL_BOOT" -L "$BUILD_LIB" -L "$PKG_DIR/lib" --compile "$f" "$out" 2>&1 | grep -v "^Error: syntax-rules" || true57
fi58
done60
# Compile examples61
echo "Compiling examples..."62
mkdir -p "$PKG_DIR/lib/examples"63
for f in "$PKG_DIR"/examples/*.sgl; do64
if [ -f "$f" ]; then65
base="$(basename "$f" .sgl)"66
out="$PKG_DIR/lib/examples/$base.sgb"67
echo " examples/$base.sgl -> $out"68
"$SGL_BOOT" -L "$BUILD_LIB" -L "$PKG_DIR/lib" --compile "$f" "$out" 2>&1 | grep -v "^Error: syntax-rules" || true69
fi70
done72
echo ""73
echo "Done! Compiled modules are in $PKG_DIR/lib"74
echo ""75
echo "To run tests (from project root):"76
echo " ./build/bin/sgl-boot -L $PKG_DIR/lib $PKG_DIR/lib/test/test-mime.sgb"77
echo ""78
echo "To run examples (from project root):"79
echo " ./build/bin/sgl-boot -L $PKG_DIR/lib $PKG_DIR/lib/examples/simple-server.sgb"