unreal自动化打包(BuildGraph)
由于是第一个项目,之前一直都是手动打包,所以最近要看看ci打包的事情!知识前提
[*]Unreal打包的基本操作
[*]AutomationTool
[*]BuildGraph
以上这三个是必然会使用到的!如果还没有接触的可以自行去看看官方的连接!
文档上的知识在这里就不照搬了!进入主题吧!
基本的结构
All.xml是所有任务的汇总 Properties.xml是整个自动化用到的属性(变量) Reset.xml是用来按需配置打包的,不用平台可能有不同的需求 PakResource.xml是pak资源的 BuildScript.xml是编译和打包的
过程及问题
ci 环境的搭建
Unreal 项目CI打包环境
具体的xml以及注意
All.xml
All.xml是一个汇总,文件划分已经做好的 All.xml
<?xml version=&#39;1.0&#39; ?>
<BuildGraph xmlns=&#34;http://www.epicgames.com/BuildGraph&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://www.epicgames.com/BuildGraph ../Schema.xsd&#34; >
<Include Script=&#34;Properties.xml&#34;/>
<Include Script=&#34;Reset.xml&#34;/>
<Include Script=&#34;BuildScript.xml&#34;/>
<Include Script=&#34;PakResource.xml&#34;/>
<Aggregate Name=&#34;All&#34; Requires=&#34;Properties Module;Reset Module;Pak Resource Module;Build Script Module&#34;/>
<Aggregate Name=&#34;Reset&#34; Requires=&#34;Properties Module;Reset Module&#34;/>
<Aggregate Name=&#34;Pak&#34; Requires=&#34;Properties Module;Build Project;Pak Resource Module&#34;/>
<Aggregate Name=&#34;Build&#34; Requires=&#34;Properties Module;Build Script Module&#34;/>
</BuildGraph> 这里有个问题,如果是Aggregate所依赖的Modeule有交叉的话,最好是把所有的Aggregate都写到一个大的xml中!
Properties.xml
Properties.xml基本是属性的声明 目前项目使用到了lua,需要对Lua进行单独的pak打包 Properties.xml
<?xml version=&#39;1.0&#39; ?>
<BuildGraph xmlns=&#34;http://www.epicgames.com/BuildGraph&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://www.epicgames.com/BuildGraph ../Schema.xsd&#34; >
<!-- Option Begins -->
<Option Name=&#34;BuildConfiguration&#34; DefaultValue=&#34;Development&#34; Description=&#34;Debug, Development or Shipping.&#34;/>
<Option Name=&#34;WithClean&#34; DefaultValue=&#34;false&#34; Description=&#34;Clean before build.&#34;/>
<Option Name=&#34;WithDebugInfo&#34; DefaultValue=&#34;false&#34; Description=&#34;Enable debug info in Development and Shipping.&#34;/>
<Option Name=&#34;WithCook&#34; DefaultValue=&#34;true&#34; Description=&#34;Cook asset.&#34;/>
<Option Name=&#34;IgnoreCookErrors&#34; DefaultValue=&#34;false&#34; Description=&#34;&#34;/>
<Option Name=&#34;IterativeCooking&#34; DefaultValue=&#34;false&#34; Description=&#34;&#34;/>
<Option Name=&#34;ProjectDir&#34; DefaultValue=&#34;&#34; Description=&#34;项目目录&#34;/>
<Option Name=&#34;ProjectName&#34; DefaultValue=&#34;&#34; Description=&#34;项目名称&#34;/>
<Option Name=&#34;BuildTarget&#34; DefaultValue=&#34;Android&#34; Description=&#34;打包的类型&#34;/>
<Option Name=&#34;IsPakLua&#34; DefaultValue=&#34;true&#34; Description=&#34;是否打包lua&#34;/>
<Option Name=&#34;IsPackage&#34; DefaultValue=&#34;true&#34; Description=&#34;是否打包成ipa/apk&#34;/>
<!-- Option Ends -->
<!-- Command Begins -->
<Property Name=&#34;UnrealProjectDir&#34; Value=&#34;$(ProjectDir)/UnrealProject&#34;/>
<!-- CleanCommand -->
<Property Name=&#34;CleanCommand&#34; Value=&#34;&#34; />
<Property Name=&#34;CleanCommand&#34; Value=&#34;-Clean&#34; If=&#34;$(WithClean)&#34;/>
<!-- BuildCommand -->
<Property Name=&#34;BuildCommand&#34; Value=&#34;-Build -NoCompileEditor -SkipBuildEditor&#34;/>
<Property Name=&#34;BuildCommand&#34; Value=&#34;$(BuildCommand) -ForceDebugInfo&#34; If=&#34;$(WithDebugInfo)&#34;/>
<!-- PakCommand -->
<Property Name=&#34;PakCommand&#34; Value=&#34;-Pak&#34;/>
<!-- CookCommand -->
<Property Name=&#34;CookCommand&#34; Value=&#34;-Cook -SkipCookingEditorContent -UnversionedCookedContent -CookPartialgc -Compressed&#34;/>
<Property Name=&#34;CookCommand&#34; Value=&#34;$(CookCommand) -IgnoreCookErrors&#34; If=&#34;$(IgnoreCookErrors)&#34;/>
<Property Name=&#34;CookCommand&#34; Value=&#34;$(CookCommand) -IterativeCooking&#34; If=&#34;$(IterativeCooking)&#34;/>
<Property Name=&#34;CookCommand&#34; Value=&#34;-SkipCook&#34; If=&#34;&#39;$(WithCook)&#39; == false&#34;/>
<!-- StageCommand -->
<Property Name=&#34;StageCommand&#34; Value=&#34;-Stage&#34;/>
<!-- PackageCommand -->
<Property Name=&#34;PackageCommand&#34; Value=&#34;&#34;/>
<Property Name=&#34;PackageCommand&#34; Value=&#34;-Package&#34; If=&#34;$(IsPackage)&#34;/>
<!-- ArchiveCommand -->
<Property Name=&#34;ArchiveCommand&#34; Value=&#34;-Archive -ArchiveDirectory=$(ProjectDir)/Binaries&#34;/>
<!-- Command -->
<Property Name=&#34;BaseCommand&#34; Value=&#34;-project=$(ProjectDir)/UnrealProject/$(ProjectName).uproject -UTF8Output -NoP4 -Prereqs $(CleanCommand) $(BuildCommand) $(PakCommand) $(CookCommand) $(StageCommand) $(ArchiveCommand)&#34;/>
<Property Name=&#34;BaseGameCommand&#34; Value=&#34;$(BaseCommand) -ClientConfig=$(BuildConfiguration) $(PackageCommand)&#34;/>
<Property Name=&#34;BaseServerCommand&#34; Value=&#34;$(BaseCommand) -DedicatedServer&#34;/>
<!-- Configs Begins -->
<!-- Android -->
<Property Name=&#34;SDKPath&#34; Value=&#34;(Path=&quot;C:/Users/UE/AppData/Local/Android/Sdk&quot;)&#34;/>
<Property Name=&#34;NDKPath&#34; Value=&#34;(Path=&quot;C:/Users/UE/AppData/Local/Android/Sdk/ndk/21.4.7075529&quot;)&#34;/>
<Property Name=&#34;JavaPath&#34; Value=&#34;(Path=&quot;C:/android/OpenJDK&quot;)&#34;/>
<Property Name=&#34;SDKAPILevel&#34; Value=&#34;latest&#34;/>
<Property Name=&#34;NDKAPILevel&#34; Value=&#34;android-21&#34;/>
<!-- Android Ends -->
<Property Name=&#34;StartMap&#34; Value=&#34;/Game/Starter/GameStarter.GameStarter&#34;/>
<Property Name=&#34;StartMap&#34; Value=&#34;/Game/Starter/GameStarter.GameStarter&#34; If=&#34;&#39;$(BuildTarget)&#39;==&#39;Android&#39;&#34;/>
<!--<Property Name=&#34;DirectoriesToNeverCook&#34; Value=&#34;(Path=&quot;/Game/TA_Demo&quot;)&#34;/>-->
<Property Name=&#34;DirectoriesToNeverCook&#34; Value=&#34;(Path=&quot;/Game/TA_Demo/Levels&quot;)
&#xA;+DirectoriesToNeverCook=(Path=&quot;/Game/TA_Demo/AnimStarterPack&quot;)
&#xA;+DirectoriesToNeverCook=(Path=&quot;/Game/TA_Demo/StarterContent&quot;)
&#xA;+DirectoriesToNeverCook=(Path=&quot;/Game/TA_Demo/Stylized_Forest&quot;)
&#xA;+DirectoriesToNeverCook=(Path=&quot;/Game/TA_Demo/Stylized_Landscape&quot;)
&#xA;+DirectoriesToNeverCook=(Path=&quot;/Game/TA_Demo/StylizedLandscapeKit&quot;)&#34;/>
<!-- 如果是多行的话 -->
<!--
<Property Name=&#34;DirectoriesToNeverCook&#34; Value=&#34;(Path=&quot;/Game/TA_Demo/Levels&quot;)
&#xA;+DirectoriesToNeverCook=(Path=&quot;/Game/TA_Demo/Levels&quot;)&#34;/>
-->
<!-- Configs Ends -->
<!-- Property Ends -->
<Agent Name=&#34;Properties Agent&#34; Type=&#34;AutoBuild&#34;>
<Node Name=&#34;Properties Module&#34;>
<Log Message=&#34;==============完成属性配置=====================&#34;/>
<Log Message=&#34;ProjectDir:$(ProjectDir)&#34;/>
<Log Message=&#34;ProjectName:$(ProjectName)&#34;/>
<Log Message=&#34;BaseGameCommand:$(BaseGameCommand)&#34;/>
<Log Message=&#34;===================================&#34;/>
</Node>
</Agent>
</BuildGraph> 因为是Properties, 所以字符串是少不了的,但是需要注意xml的一些转码! 这里提供目前我使用的,如果是其他的,可以自行google哈 &quot; : &#34; &#xA; : 换行
PakResource.xml
<?xml version=&#39;1.0&#39; ?>
<BuildGraph xmlns=&#34;http://www.epicgames.com/BuildGraph&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://www.epicgames.com/BuildGraph ../Schema.xsd&#34; >
<Agent Name=&#34;Pak Resource Agent&#34; Type=&#34;AutoBuild&#34;>
<Node Name=&#34;Delete BuildGraph Lua&#34;>
<Do If=&#34;Exists(&#39;$(ProjectDir)/BuildGraph/&#39;)&#34;>
<Delete Files=&#34;$(ProjectDir)/BuildGraph/**&#34; />
</Do>
</Node>
<Node Name=&#34;Find Framework Lua File&#34; Requires=&#34;Delete BuildGraph Lua&#34; Produces=&#34;#FrameworkLuaFiles&#34;>
<!-- 一定要在$(ProjectDir)/BuildGraph下多个Lua文件夹作为MountPoint,要不然pak的时候会报错!-->
<Copy From=&#34;$(UnrealProjectDir)/Plugins/myPlugin/Content/Lua/**&#34; To=&#34;$(ProjectDir)/BuildGraph/Lua/Plugins/myPlugin/Content/Lua/**&#34; Overwrite=&#34;true&#34; Tag=&#34;#FrameworkLuaFiles&#34;/>
</Node>
<Node Name=&#34;Find Project Lua File&#34; Produces=&#34;#ProjectLuaFiles&#34;>
<Copy From=&#34;$(UnrealProjectDir)/Content/Lua/**&#34; To=&#34;$(ProjectDir)/BuildGraph/Lua/Content/Lua/**&#34; Overwrite=&#34;true&#34; Tag=&#34;#ProjectLuaFiles&#34;/>
</Node>
<Node Name=&#34;Pak Lua&#34; If=&#34;!$(IsPakLua)&#34;>
<Log Message=&#34;不打包lua&#34;/>
</Node>
<Node Name=&#34;Pak Lua&#34; Requires=&#34;#FrameworkLuaFiles;#ProjectLuaFiles&#34; If=&#34;$(IsPakLua)&#34; After=&#34;Build Project&#34;>
<Log Message=&#34;开始打包lua&#34;/>
<!-- 一定不能有Response,要不然pak的时候,相对路径会报异常-->
<PakFile Files=&#34;#ProjectLuaFiles;#FrameworkLuaFiles&#34; Output=&#34;$(UnrealProjectDir)/Content/Paks/Lua.pak&#34; RebaseDir=&#34;$(ProjectDir)/BuildGraph/&#34;/>
<Log Message=&#34;完成打包lua&#34;/>
</Node>
<Node Name=&#34;Pak Resource Module&#34; Requires=&#34;Pak Lua&#34;>
<Log Message=&#34;执行 Pak Resource Module 完成&#34;/>
</Node>
</Agent>
</BuildGraph> 这个目前只是用来打包lua的,至于以后会不会将资源cook和独立打包资源也加进去就待定了!
BuildScript.xml
<?xml version=&#39;1.0&#39; ?>
<BuildGraph xmlns=&#34;http://www.epicgames.com/BuildGraph&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://www.epicgames.com/BuildGraph ../Schema.xsd&#34; >
<Agent Name=&#34;Tools Win64&#34; Type=&#34;AutoBuild&#34;>
<Node Name=&#34;Build Tools Win64&#34;>
<Compile Target=&#34;ShaderCompileWorker&#34; Configuration=&#34;DebugGame&#34; Platform=&#34;Win64&#34; Tag=&#34;#Build Tools Win64&#34; Clean=&#34;false&#34;/>
<Log Message=&#34;========================ShaderCompileWorker Finish&#34;/>
<Compile Target=&#34;UnrealPak&#34; Configuration=&#34;DebugGame&#34; Platform=&#34;Win64&#34; Tag=&#34;#Build Tools Win64&#34; Clean=&#34;false&#34;/>
<Log Message=&#34;========================UnrealPak Finish&#34;/>
<Compile Target=&#34;UnrealHeaderTool&#34; Configuration=&#34;DebugGame&#34; Platform=&#34;Win64&#34; Tag=&#34;#UHTFiles&#34; Clean=&#34;false&#34;/>
<Log Message=&#34;========================UnrealHeaderTool Finish&#34;/>
</Node>
</Agent>
<Agent Name=&#34;Build Project Agent&#34; Type=&#34;CompileWin64&#34;>
<Node Name=&#34;Build Project&#34; Requires=&#34;Build Tools Win64&#34;>
<!-- 一定要先generate -->
<!--<Compile Target=&#34;UE4Client&#34; Platform=&#34;Win64&#34; Configuration=&#34;Development&#34;/>-->
<!-- 一定要声明Clean,要不然每次都有几千个文件要编译!!!-->
<Compile Target=&#34;$(ProjectName)Editor&#34; Platform=&#34;Win64&#34; Configuration=&#34;Development&#34; Arguments=&#34;$(UnrealProjectDir)/$(ProjectName).uproject&#34; Clean=&#34;false&#34;/>
<Log Message=&#34;Build Project Finish&#34;/>
</Node>
</Agent>
<Agent Name=&#34;Game Win64&#34; Type=&#34;AutoBuild&#34;>
<Node Name=&#34;Build Game Win64&#34;>
<Property Name=&#34;Win64GameCommand&#34; Value=&#34;-TargetPlatform=Win64 $(BaseGameCommand)&#34;/>
<Log Message=&#34;================BuildCookRun with arguments: $(Win64GameCommand)&#34;/>
<Command Name=&#34;BuildCookRun&#34; Arguments=&#34;$(Win64GameCommand)&#34;/>
</Node>
</Agent>
<Agent Name=&#34;Game Android&#34; Type=&#34;AutoBuild&#34;>
<Node Name=&#34;Build Game Android&#34;>
<Property Name=&#34;AndroidGameCommand&#34; Value=&#34;-TargetPlatform=Android -CookFlavor=ETC2 $(BaseGameCommand)&#34;/>
<Log Message=&#34;================BuildCookRun with arguments: $(AndroidGameCommand)&#34;/>
<Command Name=&#34;BuildCookRun&#34; Arguments=&#34;$(AndroidGameCommand)&#34;/>
</Node>
</Agent>
<Agent Name=&#34;Game iOS&#34; Type=&#34;AutoBuild&#34;>
<Node Name=&#34;Build Game iOS&#34;>
<Property Name=&#34;iOSGameCommand&#34; Value=&#34;-TargetPlatform=IOS $(BaseGameCommand)&#34;/>
<Log Message=&#34;================BuildCookRun with arguments: $(iOSGameCommand)&#34;/>
<Command Name=&#34;BuildCookRun&#34; Arguments=&#34;$(iOSGameCommand)&#34;/>
</Node>
</Agent>
<!-- 打包脚本的开始 -->
<Agent Name=&#34;Build Script Agent&#34; Type=&#34;AutoBuild&#34;>
<Node Name=&#34;Build Script Module&#34; If=&#34;&#39;$(BuildTarget)&#39; == &#39;Win32&#39;&#34;>
<Log Message=&#34;执行 Build Script Module Win&#34;/>
</Node>
<Node Name=&#34;Build Script Module&#34; Requires=&#34;Build Game Win64&#34; If=&#34;&#39;$(BuildTarget)&#39;==&#39;Win64&#39;&#34;>
<Log Message=&#34;执行 Build Script Module Win64&#34;/>
</Node>
<Node Name=&#34;Build Script Module&#34; Requires=&#34;Build Game Android&#34; If=&#34;&#39;$(BuildTarget)&#39;==&#39;Android&#39;&#34;>
<Log Message=&#34;执行 Build Script Module Android&#34;/>
</Node>
<Node Name=&#34;Build Script Module&#34; Requires=&#34;Build Game iOS&#34; If=&#34;&#39;$(BuildTarget)&#39;==&#39;IOS&#39;&#34;>
<Log Message=&#34;执行 Build Script Module IOS&#34;/>
</Node>
</Agent>
</BuildGraph><hr/>AutomationTool
将工作目录改到 Engine/Build/BatchFiles。 在命令行中输入下列内容:RunUAT.bat SampleCommand(SampleCommand是自定义的指令)
页:
[1]