Files
UnrealEngineUWP/Engine/Build/BatchFiles/RunUAT.sh
josh adams f133254485 - Fixed up 3 Linux ContentWorker issues that came from the dotnet 6 upgrade (or other recent UE5 changes):
* Staged the wrong Dotnet directory when making CW from Windows (it would stage Dotnet/6.20.00/windows)
* The ScriptModule code that used the Automation.json files to discover the precompiled UAT script dlls didn't handle \'s on Linux in the paths, and since Windows wrote out the files, there are \'s aplenty. I fixed up the known issue, but possibly all paths loaded from the json files should be fixed up, but it's not easy to do automatically
* We moved to using RunUAT.sh instead of calling dotnet directly, however because we make the CW on Windows, dotnet was not executable, and the code in RunUAT.sh to find the dotnet executable and make it executable (chmod `which dotnet`) only works if dotnet is already executable! So, I moved the +x code into SetupDotnet.sh, on Linux and Mac
#rb eric.knapik
#preflight 62ccd2009922f7e512b6e51a

#ROBOMERGE-OWNER: josh.adams
#ROBOMERGE-AUTHOR: josh.adams
#ROBOMERGE-SOURCE: CL 21055451 via CL 21055464 via CL 21055478
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)
#ROBOMERGE-CONFLICT from-shelf

[CL 21076349 by josh adams in ue5-main branch]
2022-07-13 14:17:50 -04:00

152 lines
4.5 KiB
Bash
Executable File

#!/bin/bash
## Unreal Engine AutomationTool setup script
## Copyright Epic Games, Inc. All Rights Reserved.
##
## This script is expecting to exist in the Engine/Build/BatchFiles directory. It will not work
## correctly if you copy it to a different location and run it.
echo
echo Running AutomationTool...
echo
GetAllChildProcesses() {
local Children=$(ps -o pid= --ppid "$1")
for PID in $Children
do
GetAllChildProcesses "$PID"
done
echo "$Children"
}
# Gather all the descendant children of this process, and first kill -TERM. If any child process
# is still alive finally send a -KILL
TermHandler() {
MaxWait=30
CurrentWait=0
ProcessesToKill=$(GetAllChildProcesses $$)
kill -s TERM $ProcessesToKill 2> /dev/null
ProcessesStillAllive=$(ps -o pid= -p $ProcessesToKill)
# Wait until all the processes have been gracefully killed, or max Wait time
while [ -n "$ProcessesStillAllive" ] && [ "$CurrentWait" -lt "$MaxWait" ]
do
CurrentWait=$((CurrentWait + 1))
sleep 1
ProcessesStillAllive=$(ps -o pid= -p $ProcessesToKill)
done
# If some processes are still alive after MaxWait, lets just force kill them
if [ -n "$ProcessesStillAllive" ]; then
kill -s KILL $ProcessesStillAllive 2> /dev/null
fi
}
# put ourselves into Engine directory (two up from location of this script)
SCRIPT_DIR=$(cd "`dirname "$0"`" && pwd)
cd "$SCRIPT_DIR/../.."
UATCompileArg=-compile
if [ ! -f Build/BatchFiles/RunUAT.sh ]; then
echo "RunUAT ERROR: The script does not appear to be located in the "
echo "Engine/Build/BatchFiles directory. This script must be run from within that directory."
exit 1
fi
# see if we have the no compile arg
if echo "$@" | grep -q -w -i "\-nocompile"; then
UATCompileArg=
else
UATCompileArg=-compile
fi
# control toggling of msbuild verbosity for easier debugging
if echo "$@" | grep -q -w -i "\-msbuild-verbose"; then
MSBuild_Verbosity=normal
else
MSBuild_Verbosity=quiet
fi
if [ -f Build/InstalledBuild.txt ]; then
UATCompileArg=
fi
EnvironmentType=-dotnet
UATDirectory=Binaries/DotNET/AutomationTool
if [ "$(uname)" = "Darwin" ]; then
# Setup Environment
source "$SCRIPT_DIR/Mac/SetupEnvironment.sh" -mono "$SCRIPT_DIR/Mac" # ~0.4s :(
source "$SCRIPT_DIR/Mac/SetupEnvironment.sh" $EnvironmentType "$SCRIPT_DIR/Mac"
fi
if [ "$(uname)" = "Linux" ]; then
# Setup Environment
source "$SCRIPT_DIR/Linux/SetupEnvironment.sh" -mono "$SCRIPT_DIR/Linux"
source "$SCRIPT_DIR/Linux/SetupEnvironment.sh" $EnvironmentType "$SCRIPT_DIR/Linux"
fi
# Checking for out-of-date files won't find source files in places like Engine/Platform, resulting in occasionally
# out of date builds. Until a better solution is found, always try to build AutomationTool.
FORCECOMPILE_UAT=FORCE
if [ "$UATCompileArg" = "-compile" ]; then
# see if the .csproj exists to be compiled
if [ ! -f Source/Programs/AutomationTool/AutomationTool.csproj ]; then
echo No project to compile, attempting to use precompiled AutomationTool
UATCompileArg=
else
"$SCRIPT_DIR"/BuildUAT.sh $MSBuild_Verbosity $FORCECOMPILE_UAT
if [ $? -ne 0 ]; then
echo RunUAT ERROR: AutomationTool failed to compile.
exit 1
fi
fi
fi
## Run AutomationTool
#run UAT
cd $UATDirectory
if [ -z "$uebp_LogFolder" ]; then
LogDir="$HOME/Library/Logs/Unreal Engine/LocalBuildLogs"
else
LogDir="$uebp_LogFolder"
fi
# if we are running under UE, we need to run this with the term handler (otherwise canceling a UAT job from the editor
# can leave mono, etc running in the background, which means we need the PID so we
# run it in the background
if [ "$UE_DesktopUnrealProcess" = "1" ]; then
# you can't set a dotted env var nicely in sh, but env will run a command with
# a list of env vars set, including dotted ones
echo Start UAT Non-Interactively: dotnet AutomationTool.dll "$@"
trap TermHandler SIGTERM SIGINT
env uebp_LogFolder="$LogDir" dotnet AutomationTool.dll "$@" &
UATPid=$!
wait $UATPid
else
# you can't set a dotted env var nicely in sh, but env will run a command with
# a list of env vars set, including dotted ones
echo Start UAT Interactively: dotnet AutomationTool.dll "$@"
which dotnet
env uebp_LogFolder="$LogDir" dotnet AutomationTool.dll "$@"
fi
UATReturn=$?
# @todo: Copy log files to somewhere useful
# if not "%uebp_LogFolder%" == "" copy log*.txt %uebp_LogFolder%\UAT_*.*
# if "%uebp_LogFolder%" == "" copy log*.txt c:\LocalBuildLogs\UAT_*.*
#cp log*.txt /var/log
if [ $UATReturn -ne 0 ]; then
echo RunUAT ERROR: AutomationTool was unable to run successfully. Exited with code: $UATReturn
exit $UATReturn
fi