Files
Spine_lab/viewpanel/run.sh
T

53 lines
2.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/zsh
# 手动重启编辑器(实验室版):
# ./viewpanel/run.sh # 打开默认样例
# ./viewpanel/run.sh <某个.spine> # 打开指定工程
#
# 做的事:①杀掉已在跑的实例(避免同时开好几个 Spine 窗口)
# ②源码比 class 新就自动 rebuild ③启动编辑器(后台,日志 /tmp/spineview.log)
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
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}"
echo "== 关掉旧实例"
pkill -f com.spineview.Launcher 2>/dev/null || true
sleep 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
echo "== 启动(工程 $PROJ)"
# 注意:不能用 `nohup … &` —— 那样进程挂在本 shell 的会话里,跑这条命令的终端一结束
# 编辑器就被一起收掉。必须 start_new_session=True 让它彻底脱离会话。
python3 - "$JX" "$ROOT" "$HERE" "$PAY" "$PROJ" "$LOG" <<'PYEOF'
import os, subprocess, sys
jx, root, here, pay, proj, log = sys.argv[1:7]
cmd = [jx,
"-javaagent:" + root + "/tools/agent/view-agent.jar",
"-DSpineJava=1",
"-Dspine.payload=" + pay,
"-Dspine.resources=" + here + "/resources",
"-Dspine.compat=" + here + "/compat-classes",
"-Dpanel.h=" + (os.environ.get("PANEL_H") or "984"),
"-Dspine.classes=" + here + "/build/classes",
"-Duser.home=" + root + "/spine-lab/home",
"-cp", here + "/build/classes:" + root + "/tools/asm/asm.jar:" + root + "/tools/asm/asm-tree.jar",
"com.spineview.Launcher", proj]
with open(log, "ab") as out:
subprocess.Popen(cmd, stdout=out, stderr=out, start_new_session=True)
print("launched")
PYEOF
sleep 2
echo "== 已启动:pid $(pgrep -f com.spineview.Launcher | tr '\n' ' ')"
echo " 日志:tail -f $LOG"