AtlatestRepositorysigil-http

sigil-http / treecompile.sh

1#!/usr/bin/env bash
2# Compile sigil-http library modules to ./lib for testing
3# Usage: ./compile.sh
4
5set -e
6
7SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
9
10# sgl-boot must run from project root to find stdlib/prelude.sgl
11cd "$PROJECT_ROOT"
13SGL_BOOT="./build/bin/sgl-boot"
14if [ ! -x "$SGL_BOOT" ]; then
15 echo "Error: sgl-boot not found at $SGL_BOOT. Build sigil first."
16 exit 1
17fi
19echo "Using: $SGL_BOOT (from $PROJECT_ROOT)"
21BUILD_LIB="./build/lib"
22if [ ! -d "$BUILD_LIB" ]; then
23 echo "Error: build/lib not found. Build sigil first."
24 exit 1
25fi
27PKG_DIR="packages/sigil-http"
29# Create output directories
30mkdir -p "$PKG_DIR/lib/sigil/http"
32# Compile library modules
33echo "Compiling library modules..."
34for 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; do
39 src="$PKG_DIR/$f"
40 if [ -f "$src" ]; then
41 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" || true
45 fi
46done
48# Compile test files
49echo "Compiling tests..."
50mkdir -p "$PKG_DIR/lib/test"
51for f in "$PKG_DIR"/test/*.sgl; do
52 if [ -f "$f" ]; then
53 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" || true
57 fi
58done
60# Compile examples
61echo "Compiling examples..."
62mkdir -p "$PKG_DIR/lib/examples"
63for f in "$PKG_DIR"/examples/*.sgl; do
64 if [ -f "$f" ]; then
65 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" || true
69 fi
70done
72echo ""
73echo "Done! Compiled modules are in $PKG_DIR/lib"
74echo ""
75echo "To run tests (from project root):"
76echo " ./build/bin/sgl-boot -L $PKG_DIR/lib $PKG_DIR/lib/test/test-mime.sgb"
77echo ""
78echo "To run examples (from project root):"
79echo " ./build/bin/sgl-boot -L $PKG_DIR/lib $PKG_DIR/lib/examples/simple-server.sgb"