rinkplanner/tools/export_web.sh

34 lines
958 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PROJECT_DIR="$REPO_ROOT/rinkplanner"
BUILD_DIR="$REPO_ROOT/build/web"
GODOT="${GODOT:-/opt/godot/Godot_v4.7.2-stable_linux.x86_64}"
if [[ ! -x "$GODOT" ]]; then
echo "Godot binary not found: $GODOT" >&2
echo "Set GODOT=/path/to/godot" >&2
exit 1
fi
"$GODOT" --headless --path "$PROJECT_DIR" --import >/dev/null
mkdir -p "$BUILD_DIR"
if ! "$GODOT" --headless --path "$PROJECT_DIR" \
--export-release "Web" "$BUILD_DIR/index.html"; then
echo "Web export failed." >&2
echo "Check that the Web export templates for this Godot version are installed" >&2
echo "(Editor -> Manage Export Templates)." >&2
exit 1
fi
if [[ ! -f "$BUILD_DIR/index.html" ]]; then
echo "Web export produced no index.html." >&2
exit 1
fi
echo "Web build: $BUILD_DIR/index.html"
echo "Serve it with:"
echo " python3 -m http.server 8000 --directory \"$BUILD_DIR\""