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"