Skip to content

Instantly share code, notes, and snippets.

@RicardoEPRodrigues
Last active June 12, 2023 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RicardoEPRodrigues/2bc4b5217b86252158eb5049df7e9d95 to your computer and use it in GitHub Desktop.
Save RicardoEPRodrigues/2bc4b5217b86252158eb5049df7e9d95 to your computer and use it in GitHub Desktop.
Unreal Engine UAT Game Build Automation (Win/Linux)
#!/bin/bash
set -e
set +x
echo "Building Game for Linux..."
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DIR="${DIR}/Build/"
PROJECT="${DIR}/Game.uproject"
TARGET="CPPThirdPerson"
UE_DIR="/path/to/Unreal Engine/5.1.0"
UE_UAT="${UE_DIR}/Engine/Build/BatchFiles/RunUAT.sh"
PLATFORM="Linux"
# Get unreal engine version from uproject file.
UE_VERSION=$(grep "EngineAssociation" "${PROJECT}" | cut -d '"' -f 4)
echo "Game will use Unreal Engine ${UE_VERSION}..."
# load unreal engine installs from ~/.config/Epic/UnrealEngine/Install.ini
if [ ! -f ~/.config/Epic/UnrealEngine/Install.ini ]; then
echo "No Unreal Engine installations found. Please install Unreal Engine ${UE_VERSION}."
exit 1
fi
# Get the path to the Unreal Engine version.
UE_DIR=$(grep "${UE_VERSION}=" ~/.config/Epic/UnrealEngine/Install.ini | cut -d '=' -f 2)
if [ -z "${UE_DIR}" ]; then
echo "Unreal Engine ${UE_VERSION} not found. Please install Unreal Engine ${UE_VERSION}."
exit 1
fi
# Get the path to the Unreal Engine UAT.
UE_UAT="${UE_DIR}/Engine/Build/BatchFiles/RunUAT.sh"
if [ -z "${UE_UAT}" ]; then
echo "Unreal Engine ${UE_VERSION} UAT not found. Please install Unreal Engine ${UE_VERSION}."
exit 1
fi
echo "Found Unreal Engine ${UE_VERSION}. Building..."
cd "${UE_DIR}"
set -x
"${UE_UAT}" BuildCookRun \
-project="${PROJECT}" -target=${TARGET} -clientconfig=Shipping \
-package -platform=${PLATFORM} \
-archive -archivedirectory="${BUILD_DIR}" \
-compile -build -cook -stage \
-nop4 -iostore -pak -prereqs -nodebuginfo -installed -compressed
@echo off
title Build Game
set DIR=%~dp0
set BUILD_DIR=%DIR%Build
set PROJECT=%DIR%Game.uproject
set TARGET=CPPThirdPerson
set UE_DIR=D:\Program Files\Epic Games\UE_5.1
set UE_UAT=%UE_DIR%\Engine\Build\BatchFiles\RunUAT.bat
set PLATFORM=Win64
@REM Get unreal engine version from uproject file.
for /f "tokens=2 delims=:" %%a in ('findstr "EngineAssociation" "%PROJECT%"') do (
set UE_VERSION=%%a
)
set UE_VERSION=%UE_VERSION: =%
set UE_VERSION=%UE_VERSION:"=%
set UE_VERSION=%UE_VERSION:~0,-1%
echo Game will use Unreal Engine %UE_VERSION%...
@REM load unreal engine installs from registry
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%UE_VERSION%" /v "InstalledDirectory" 2^>^&1^|find "REG_"') do (
set UE_DIR=%%b
)
if not exist "%UE_DIR%" (
echo Unreal Engine installation not found.
echo Please install Unreal Engine %UE_VERSION%.
echo https://www.unrealengine.com/en-US/download
pause
exit
)
set UE_UAT=%UE_DIR%\Engine\Build\BatchFiles\RunUAT.bat
if not exist "%UE_UAT%" (
echo Unreal Engine installation not found.
echo Please install Unreal Engine %UE_VERSION%.
echo https://www.unrealengine.com/en-US/download
pause
exit
)
@REM Build.
echo Found Unreal Engine %UE_VERSION%. Building...
cd "%UE_DIR%"
call "%UE_UAT%" ^
BuildCookRun ^
-project="%PROJECT%" -target=%TARGET% -clientconfig=Shipping ^
-package -platform=%PLATFORM% ^
-archive -archivedirectory="%BUILD_DIR%" ^
-compile -build -cook -stage ^
-nop4 -iostore -pak -prereqs -nodebuginfo -installed -compressed
@echo on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment