Linked repository source
examples/setup.sh
This read-only view comes from the file in the Gododin repository. It retains its design, example or evidence context.
Download the original file · Return to the guide
#!/bin/bash
# One-time wiring for the configured examples: write each example's ignored
# .gododin/local.toml, attach the extracted immutable SDK, and verify the
# result with doctor. Machine-local state only; .gododin/ is git-ignored.
#
# The manual equivalent (attach plus a hand-written local.toml) is documented
# in docs/getting-started.md; the example READMEs own what runs after setup.
set -euo pipefail
export LC_ALL=C
usage() {
echo "usage: $0 --sdk <sdk-root> --odin <odin-executable> --godot <godot-executable> [example ...]" >&2
echo " example names default to all of: ripple_pond bunny_mark boid_flock slime_colony voxel_stream cavern_lab" >&2
echo " input paths may be relative to the current directory; the stored configuration" >&2
echo " canonicalizes them, because the CLI requires exact absolute paths" >&2
exit 64
}
repo_root="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
sdk=""
odin=""
godot=""
names=()
while [[ $# -gt 0 ]]; do
case "$1" in
--sdk|--odin|--godot)
[[ $# -ge 2 ]] || usage
case "$1" in --sdk) sdk="$2" ;; --odin) odin="$2" ;; --godot) godot="$2" ;; esac
shift 2
;;
-h|--help) usage ;;
*) names+=("$1"); shift ;;
esac
done
[[ -n "$sdk" && -n "$odin" && -n "$godot" ]] || usage
canonical() {
python3 - "$1" <<'CANON'
import os, sys
path = os.path.realpath(sys.argv[1])
if not os.path.isabs(path) or not os.path.exists(path):
sys.exit("error: not an existing absolute path: " + sys.argv[1])
print(path)
CANON
}
sdk="$(canonical "$sdk")"
odin="$(canonical "$odin")"
godot="$(canonical "$godot")"
cli="$sdk/bin/gododin"
[[ -x "$cli" ]] || { echo "error: no executable at $cli" >&2; exit 65; }
[[ -x "$odin" ]] || { echo "error: configured Odin is not executable: $odin" >&2; exit 65; }
[[ -x "$godot" ]] || { echo "error: configured Godot is not executable: $godot" >&2; exit 65; }
if [[ ${#names[@]} -eq 0 ]]; then
names=(ripple_pond bunny_mark boid_flock slime_colony voxel_stream cavern_lab rewind_lab)
fi
odin_root="$(dirname "$odin")"
for name in "${names[@]}"; do
example="$repo_root/examples/$name"
[[ -f "$example/gododin.toml" ]] || { echo "error: $example is not a configured Gododin project" >&2; exit 65; }
example="$(cd -P -- "$example" && pwd -P)"
local_root="$example/.gododin"
mkdir -p -m 700 "$local_root"
mkdir -p "$local_root/first-home" "$local_root/first-tmp" "$local_root/godot-home"
candidate="$local_root/local.toml.candidate"
cat > "$candidate" <<TOML
format = 1
[first_cli]
mode = "external_odin"
[first_cli.external_odin]
executable_path = "$odin"
odin_root = "$odin_root"
home_directory = "$local_root/first-home"
temporary_directory = "$local_root/first-tmp"
[godot]
home_directory = "$local_root/godot-home"
[godot.executables]
godot_4_8_0_executable = "$godot"
TOML
mv "$candidate" "$local_root/local.toml"
echo "== $name: attach =="
"$cli" attach --project-root "$example"
echo "== $name: doctor =="
"$cli" doctor --project-root "$example"
echo "== $name: configured; enter with: cd examples/$name && ./test.sh"
done