BurningTimesAi/공유/기획/FirstRising/UI/tools/evd.sh

28 lines
1.3 KiB
Bash

#!/bin/bash
# 오래 걸리는 eval 을 분리 실행(--detach)으로 돌리고 끝날 때까지 기다린다. source evd.sh 뒤 evd <스크립트 이름> [인수...]
# CLI 는 5초를 넘기면 에디터 콘솔에 빨간 오류를 남기므로, 씬을 여는 일처럼 긴 것은 이것으로 돌린다
evd() {
local f="$1"; shift
if [ $# -gt 0 ]; then printf "%s" "$*" > "$SP/eval/args.txt"; fi
local J=$(unity command eval_file --file "$SP/eval/$f.cs" --project-path "$P" --detach --format json --no-banner 2>&1 | grep -o '"jobId": *"[a-f0-9]*"' | grep -o '[a-f0-9]\{32\}')
if [ -z "$J" ]; then echo "작업 번호를 받지 못함"; return 1; fi
unity job wait "$J" --project-path "$P" --format json --no-banner 2>&1 | python -c "
import sys, json
raw = sys.stdin.read()
try:
d = json.loads(raw)
except Exception:
print('PARSE FAIL', raw[:800]); sys.exit(0)
data = d.get('data') or {}
job = data.get('job') or data
res = job.get('result')
if isinstance(res, dict):
inner = res.get('result')
print(inner if inner is not None else json.dumps(res, ensure_ascii=False)[:1500])
if res.get('error'): print('EVAL ERROR', res.get('error'), res.get('errorDetails'))
else:
print('state', job.get('state'), '| result', res, '| error', job.get('error'))
if d.get('errors'): print('ERR', d.get('errors'))
"
}