2021-01-30 15:18:47 +01:00
|
|
|
# osx unity build shell script
|
|
|
|
|
|
|
|
# $1 UNITY_VERSION
|
|
|
|
unityversion=$1
|
|
|
|
|
2021-02-01 19:00:00 +01:00
|
|
|
editorlogpath="$(pwd)/Editor.log"
|
2021-01-30 15:18:47 +01:00
|
|
|
editorpath="/Applications/Unity/Hub/Editor/$unityversion/Unity.app"
|
|
|
|
|
|
|
|
# remove previous Editor.log
|
|
|
|
echo "removing previous editor log..."
|
|
|
|
[ -f $editorlogpath ] && rm $editorlogpath
|
|
|
|
|
|
|
|
echo "starting build using unity v$unityversion..."
|
|
|
|
|
|
|
|
# launch unity in batch mode
|
|
|
|
open -g $editorpath --args \
|
|
|
|
-batchmode \
|
|
|
|
-quit \
|
|
|
|
-nographics \
|
2021-03-05 13:52:28 +01:00
|
|
|
-developmentBuild \
|
2021-01-30 15:18:47 +01:00
|
|
|
-executeMethod "Ktyl.Util.BuildCommand.Run" \
|
|
|
|
-logFile $editorlogpath \
|
|
|
|
-projectPath "$(pwd)/game"
|
|
|
|
|
2021-02-01 20:36:39 +01:00
|
|
|
# wait for editor log to exist
|
2021-03-02 19:44:59 +01:00
|
|
|
tries=60
|
2021-02-15 18:12:44 +01:00
|
|
|
count=0
|
2021-02-01 20:37:37 +01:00
|
|
|
while [ ! -f $editorlogpath ]
|
2021-02-01 20:36:39 +01:00
|
|
|
do
|
|
|
|
sleep 1
|
2021-02-15 18:12:44 +01:00
|
|
|
|
|
|
|
# decrement
|
|
|
|
count=`expr $count + 1`
|
|
|
|
|
|
|
|
if [ $count -eq $tries ] ; then
|
2021-03-02 19:44:59 +01:00
|
|
|
echo "early timeout - $tries seconds elapsed since launch attempt"
|
|
|
|
exit 1
|
2021-02-15 18:12:44 +01:00
|
|
|
fi
|
2021-02-01 20:36:39 +01:00
|
|
|
done
|
|
|
|
|
2021-02-01 19:00:00 +01:00
|
|
|
# use a safe directory that is automatically removed by the shell when the script exists
|
|
|
|
work="$(mktemp -d)" || exit $?
|
|
|
|
trap "rm -rf '$work'" exit
|
|
|
|
|
|
|
|
# default exit code
|
|
|
|
echo 1 > $work/exitcode
|
|
|
|
|
|
|
|
# start tail in a subshell and store its pid, then read line by line to determine build result
|
|
|
|
(tail -n 1 -f $editorlogpath &
|
|
|
|
jobs -p %% > "$work/tail.pid"
|
|
|
|
) | while read line
|
2021-01-30 15:18:47 +01:00
|
|
|
do
|
2021-02-01 19:00:00 +01:00
|
|
|
echo "${line}"
|
|
|
|
|
|
|
|
# check for build success
|
|
|
|
if [[ $line == *":: ktyl.build completed with code 0"* ]]; then
|
|
|
|
echo 0 > $work/exitcode
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check for exit
|
|
|
|
# TODO: ideally we should have a better indicator than the package manager's shutdown message
|
|
|
|
if [[ $line == *"[Package Manager] Server::Kill -- Server was shutdown"* ]]; then
|
|
|
|
break
|
|
|
|
fi
|
2021-01-30 15:18:47 +01:00
|
|
|
done
|
|
|
|
|
2021-02-01 19:00:00 +01:00
|
|
|
# kill zombie tail process
|
|
|
|
kill $(<"$work/tail.pid")
|
|
|
|
|
2021-02-01 21:13:24 +01:00
|
|
|
# exit with unity's exit code
|
|
|
|
exit $(cat $work/exitcode)
|
2021-02-01 19:00:00 +01:00
|
|
|
|
|
|
|
# vim: tabstop=4 shiftwidth=4 expandtab
|