From c6d9ff1a26a3a9fccc947f92fb9ed3941fdb5856 Mon Sep 17 00:00:00 2001 From: Emil Date: Wed, 2 Sep 2026 17:16:24 +0300 Subject: [PATCH] Add scripts/stage-plugins.sh and run-sample.sh for running the engine locally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contracts and Implementation build into two separate bin/ folders, so there's nowhere valid to point --plugins at without a staging step first — every manual verification this session has done that staging by hand. stage-plugins.sh does it for every plugin in one pass; run-sample.sh stages then runs samples/WindowDemo windowed, forwarding extra args to `engine run` (e.g. --screenshot). Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N --- .gitignore | 3 +++ scripts/run-sample.sh | 14 ++++++++++++++ scripts/stage-plugins.sh | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100755 scripts/run-sample.sh create mode 100755 scripts/stage-plugins.sh diff --git a/.gitignore b/.gitignore index 5d71e09..394abaf 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,9 @@ Thumbs.db out/ artifacts/ +## scripts/stage-plugins.sh's output — regenerated from plugins/, not source. +.stage/ + ## ImGui's own persisted window layout (position/size/open-state) — a ## per-machine editing session preference, not project source, same ## category as an IDE's own workspace state. diff --git a/scripts/run-sample.sh b/scripts/run-sample.sh new file mode 100755 index 0000000..60f1791 --- /dev/null +++ b/scripts/run-sample.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Stages every plugin, then runs samples/WindowDemo windowed. Extra args +# are forwarded to `engine run` — e.g. ./run-sample.sh --screenshot out.png +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +CONFIG="${CONFIGURATION:-Debug}" +STAGE_DIR="$REPO_ROOT/.stage/plugins" + +"$REPO_ROOT/scripts/stage-plugins.sh" "$STAGE_DIR" + +cd "$REPO_ROOT/samples/WindowDemo" +exec dotnet "$REPO_ROOT/src/Engine.Host/bin/$CONFIG/net9.0/Engine.Host.dll" run --windowed \ + --plugins "$STAGE_DIR" --project project.json --scene scene.json "$@" diff --git a/scripts/stage-plugins.sh b/scripts/stage-plugins.sh new file mode 100755 index 0000000..51a666b --- /dev/null +++ b/scripts/stage-plugins.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Builds every plugin and lays each one out into a single flat directory +# per id — plugin.json alongside its built DLLs — which is the layout +# PluginHost.Load actually expects. Needed because Contracts and +# Implementation build into two separate bin/ folders; without this step +# there's nowhere valid to point --plugins at. +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +STAGE_DIR="${1:-$REPO_ROOT/.stage/plugins}" +CONFIG="${CONFIGURATION:-Debug}" + +echo "Building solution ($CONFIG)..." +dotnet build "$REPO_ROOT/LinguaEngine.sln" -c "$CONFIG" >/dev/null + +rm -rf "$STAGE_DIR" +mkdir -p "$STAGE_DIR" + +for plugin_dir in "$REPO_ROOT"/plugins/*/; do + id="$(basename "$plugin_dir")" + [ -f "$plugin_dir/plugin.json" ] || continue + + # engine.foo -> Engine.Foo (the Implementation project's folder name) + impl_name="$(awk -F. '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1)) substr($i,2)}}1' OFS=. <<<"$id")" + impl_out="$plugin_dir/$impl_name/bin/$CONFIG/net9.0" + + if [ ! -d "$impl_out" ]; then + echo "warning: no build output for '$id' at $impl_out, skipping" >&2 + continue + fi + + mkdir -p "$STAGE_DIR/$id" + cp -r "$impl_out/." "$STAGE_DIR/$id/" + cp "$plugin_dir/plugin.json" "$STAGE_DIR/$id/" +done + +echo "Staged plugins into: $STAGE_DIR"