kill existing unity processes before attempting build

This commit is contained in:
Cat Flynn 2021-01-30 14:16:26 +00:00
parent d28a2b22c5
commit 6290dde9db
1 changed files with 47 additions and 40 deletions

View File

@ -1,40 +1,47 @@
# osx unity build shell script # osx unity build shell script
# $1 UNITY_VERSION # $1 UNITY_VERSION
unityversion=$1 unityversion=$1
editorpath="/Applications/Unity/Hub/Editor/$unityversion/Unity.app" editorlogpath="$HOME/Library/Logs/Unity/Editor.log"
editorpath="/Applications/Unity/Hub/Editor/$unityversion/Unity.app"
# remove previous Editor.log
editorlogpath="$HOME/Library/Logs/Unity/Editor.log" # find and kill existing unity instances
[ -f $editorlogpath ] && rm $editorlogpath if pgrep -x Unity
then
echo "starting build using unity v$unityversion..." echo "terminating existing unity processes..."
kill $(pgrep Unity)
# launch unity in batch mode fi
open -g $editorpath --args \
-batchmode \ # remove previous Editor.log
-quit \ echo "removing previous editor log..."
-nographics \ [ -f $editorlogpath ] && rm $editorlogpath
-executeMethod "Ktyl.Util.BuildCommand.Run" \
-logFile $editorlogpath \ echo "starting build using unity v$unityversion..."
-projectPath "$(pwd)/game"
# launch unity in batch mode
# wait for unity to exit open -g $editorpath --args \
while pgrep -x "Unity" > /dev/null -batchmode \
do -quit \
sleep 1 -nographics \
done -executeMethod "Ktyl.Util.BuildCommand.Run" \
-logFile $editorlogpath \
-projectPath "$(pwd)/game"
if [ -f $editorlogpath ]; then
echo "build completed, dumping log" # wait for unity to exit
cat $editorlogpath while pgrep -x Unity > /dev/null
echo "TODO: check result of build by looking at the last few lines" do
else sleep 1
echo "no editor log to dump?" done
fi
if [ -f $editorlogpath ]; then
echo "build completed, dumping log"
cat $editorlogpath
echo "TODO: check result of build by looking at the last few lines"
else
echo "no editor log to dump?"
fi