加 viewpanel/run.sh:一条命令手动重启编辑器(先杀旧实例、按需 rebuild、日志写 /tmp/spineview.log)

This commit is contained in:
tianmo committed 2026-10-16 15:46:40 +08:00
1 parent 15468829ae
commit e5461cbf12
2 files changed
+34 -25

No files matched your search

Binary file not shown.
+34 -25
View File
@@ -1,33 +1,42 @@
#!/bin/zsh
# 启动实验室副本并注入 ViewPanel。
# 用 LaunchServices(open -n)启动,这样进程有启动时间,REA 的运行时 UI 观测才认。
# 手动重启编辑器(实验室版):
# ./viewpanel/run.sh # 打开默认样例
# ./viewpanel/run.sh <某个.spine> # 打开指定工程
#
# 做的事:①杀掉已在跑的实例(避免同时开好几个 Spine 窗口)
# ②源码比 class 新就自动 rebuild ③启动编辑器(后台,日志 /tmp/spineview.log)
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
LAB="$HERE/../spine-lab"
ROOT="$(cd "$HERE/.." && pwd)"
JX="$ROOT/tools/jdk8u504-b01/Contents/Home/bin/java"
ASM="$ROOT/tools/asm/asm.jar:$ROOT/tools/asm/asm-tree.jar"
PAY="$ROOT/spine-lab/home/Library/Application Support/Spine/updates/3.8.99.orig"
PROJ="${1:-$ROOT/sample/3.8.99/3899.spine}"
LOG="${SPINEVIEW_LOG:-/tmp/spineview.log}"
[[ -f "$HERE/build/inject.dylib" ]] || { echo "先跑 ./build.sh" >&2; exit 1; }
echo "== 关掉旧实例"
pkill -f com.spineview.Launcher 2>/dev/null || true
sleep 1
# 先关掉旧的实验室实例,避免测试时越开越多。
for pid in $(/bin/ps -eo pid,command | grep "$LAB/Spine.app/Contents/MacOS/Spine" | grep -v grep | awk '{print $1}'); do
kill "$pid" 2>/dev/null && echo "关掉旧实例 pid=$pid"
done
sleep 2
echo "注入器 : $HERE/build/inject.dylib"
echo "面板类 : $HERE/build/classes"
echo "日志 : /tmp/spine-viewpanel.log"
# 可选:把工程文件一起打开(第一个参数)
PROJECT_ARGS=()
if [[ -n "$1" ]]; then
PROJECT_ARGS=(--args "$1")
echo "工程 : $1"
if [[ ! -f "$HERE/build/classes/com/spineview/Launcher.class" ]] \
|| [[ -n "$(find "$HERE/src" -newer "$HERE/build/classes/com/spineview/Launcher.class" 2>/dev/null | head -1)" ]]; then
echo "== 源码有更新,先编译"
JAVA_HOME="${JAVA_HOME:-/tmp/jdk-17.0.20.1+1/Contents/Home}" "$HERE/build.sh" | tail -3
fi
open -n \
--env "DYLD_INSERT_LIBRARIES=$HERE/build/inject.dylib" \
--env "SPINE_VIEWPANEL_CLASSES=$HERE/build/classes" \
--env "SPINE_VIEWPANEL_MAIN=com/spineview/SceneScan" \
--env "SPINE_USER_HOME=$LAB/home" \
"$LAB/Spine.app" "${PROJECT_ARGS[@]}"
echo "== 启动(工程 $PROJ)"
nohup "$JX" \
"-javaagent:$ROOT/tools/agent/view-agent.jar" \
-DSpineJava=1 \
"-Dspine.payload=$PAY" \
"-Dspine.resources=$HERE/resources" \
"-Dspine.compat=$HERE/compat-classes" \
"-Dspine.classes=$HERE/build/classes" \
"-Duser.home=$ROOT/spine-lab/home" \
-cp "$HERE/build/classes:$ASM" com.spineview.Launcher "$PROJ" \
>"$LOG" 2>&1 &
sleep 2
echo "== 已启动:pid $(pgrep -f com.spineview.Launcher | tr '\n' ' ')"
echo " 日志:tail -f $LOG"