UE4持续集成打包(Mac脚本自动化打包)

主要通过RunUAT进行打包,win和mac均可以打包,本次打包实现在Mac环境下,使用/Engine/Build/BatchFiles/RunUAT.sh

参考命令格式(参考文献1):

RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -allmaps -build -stage -pak -archive -archivedirectory="Output Directory"

具体参数在UE4的launch进行构建的开始阶段会在控制台输出,可以参考。

其中RunUAT需要写全路径,我这里构建命令如下,输出apk默认在/Binaries/Android/文件夹下

"/Users/Shared/Epic Games/UE_4.21/Engine/Build/BatchFiles/RunUAT.sh" BuildCookRun  -project=/Demo_ForMac_Android/Demo.uproject -noP4 -clientconfig=Development -serverconfig=Development -nocompile -nocompileeditor -installed -ue4exe=UE4Editor -utf8output -platform=Android_ASTC -targetplatform=Android -cookflavor=ASTC -build -map=/Game/Maps/NewMap1 -skipcook -compressed -stage

补充ipa

"/Users/Shared/Epic Games/UE_4.22/Engine/Build/BatchFiles/RunUAT.sh" BuildCookRun -project="/export/jenkins/workspace/Demo_ForMac_iOS2/Demo/Demo.uproject" -noP4 -clientconfig=Development -serverconfig=Development -nocompile -nocompileeditor -ue4exe='/Users/Shared/Epic Games/UE_4.22/Engine/Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor' -utf8output -platform=IOS -build -map=/Game/Maps/NewMap -skipcook -CookInEditor -iterativecooking -compressed -stage

参考文献:

1、https://wiki.unrealengine.com/How_to_package_your_game_with_commands

2、https://api.unrealengine.com/CHN/Engine/Basics/Projects/Packaging/index.html(未使用,说明详细)

3、https://www.jianshu.com/p/8e2b0da24d8d

4、https://www.jianshu.com/p/b3954b2ac62f

5、https://zhuanlan.zhihu.com/p/41931214

2019-04-29补充命令行参数详解:转载自https://zhuanlan.zhihu.com/p/41931214

基本参数

  • -CrashReporter: 编译CrashReporter
  • -Clean: 重新完整构建
  • -SignedPak: 使用加密的pak文件
  • -SignPak=C:\Encryption.keys 或者 -signpak=0x…..: 指定加密pak文件密钥内容或者密钥文件路径,密钥内容以 0x 开头,同时 -SignedPak 参数也生效
  • -RunAssetNativization: 将蓝图资产转成代码
  • -Pak: 是否将资源文件打包到pak中,但是并不是说不指定这个命令行就不用pak,有些平台只能用pak(比如Android打包成apk),不管有没有这个参数,具体见各个平台对Engine\Source\Programs\AutomationTool\AutomationUtils\Platform.cs类中RequiresPak函数的重载
  • -SkipPak: 使用上一次的pak文件,包含-Pak
  • -UTF8Output: log,控制台窗口等输出使用UTF8编码

Build相关参数

  • -Build: 执行编译过程
  • -SkipBuildClient: 不编译客户端
  • -SkipBuildEditor: 不编译编辑器
  • -NoXGE: 不使用并行编译
  • -ForceDebugInfo: 在非Debug版本中加入调试信息

Cook相关参数

  • -Cook: 使用Cooked资源
  • -SkipCook: 跳过cook阶段,使用上一次Cook好的资源,同时包含了 -Cook 参数
  • -IgnoreCookErrors: 忽略cook过程中的错误
  • -CookFlavor=Multi/ATC/DXT/ETC1/ETC2/PVRTC/ASTC: 指定Android Cook格式
  • -CookPartialGC: cook阶段磁盘空间不够不要清理所有资源
  • -CookInEditor: 使用editor进行cook而不是UAT
  • -CookOutputDir=C:\cooked: 指定cook结果保存目录,默认在Project/Saved/Cooked(使用UAT cook)和Project/Saved/EditorCooked(使用editor cook)
  • -AdditionalCookerOptions=xxx: 额外的传给cooker进程的命令行
  • -Compressed: 压缩
  • -EncryptIniFiles: 加密ini文件,只在指定了加密密钥和使用pak文件时候有效
  • -EncryptEverything: 加密所有的文件,只在指定了加密密钥和使用pak文件时候有效
  • -EncryptPakIndex: 加密pak索引,只在指定了加密密钥和使用pak文件时候有效
  • -UnversionedCookedContent: 不包含版本号
  • -IterativeCooking(-Iterate): 增量cook
  • -CookAll: cook content目录下的所有文件
  • -CookMapsOnly: 只cook关卡和关卡引用到的资源,只会在同时指定了-CookAll时生效
  • -MapsToCook=map1+map2+map3: 指定要cook的关卡,多个之间用+号连接
  • -SkipCookingEditorContent: 不cook引擎编辑器使用到的资源
  • -NumCookersToSpawn=n: 指定cooker进程的数量
  • -FastCook: 开启FastCook,如果项目支持的话

Stage相关参数

  • -Stage: 保存构建过程中的中间结果
  • -SkipStage: 不保存构造过程中的中间结果,使用上一次的结果,这个命令行同时包含了 -Stage
  • -StagingDirectory=C:\xxxx: 构建过程中中间结果保存目录,默认在ProjectPath\Saved\StagedBuilds
  • -NoDebugInfo: 不拷贝调试信息文件到Stage目录,也就是最终打出来的包中不包含调试信息
  • -NoCleanStage: 新构建不会清理之前StagingDirectory中的文件, 如果指定了-clean则一定会清理掉
  • -StageCommandline=xxxx: 放在UE4CommandLine.txt中的一系列命令行,打出来的包在运行时会从这个文件中读取命令行并执行

Run相关参数

  • -Run: 构建完成后运行游戏
  • -CookOnTheFly: 使用服务器上的cook过的资源
  • -CookOnTheFlyStreaming: 同上,但是不缓存资源到本地
  • -FileServer: 使用UnrealFileServer上的cook过的资源数据
  • -DedicatedServer(-Server): 构建完成后运行ds服务器
  • -Client: 使用TargetType.Client对应的配置运行游戏
  • -NoClient: 只运行服务器
  • -LogWindow: 创建日志窗口
  • -Map=xxx: 指定游戏运行的关卡
  • -AdditionalServerMapParams=?param=value:服务器地图的额外参数
  • -NumClients=n: 客户端数量
  • -AddCmdline=/-ServerCommandline=/-ClientCommandline=xx: 额外的进程参数

Package相关参数

  • -Package: 执行打包,Andorid->apk, iOS->ipa
  • -Distribution: 打的包是发布版本,在Android和iOS上会禁掉Debugable属性
  • -Prereqs: 将依赖打包到一起

Archive相关参数

  • -Archive: 是否将构建结果归档到指定目录
  • -ArchiveDirectory: 归档目录,默认为ProjectPath\ArchivedBuilds
  • -CreateAppBundle: 当目标平台是Mac时,指定这个参数可以归档成一个 .app 文件而不是一堆散文件

Deploy相关参数

  • -Deploy: 部署
  • -DeployFolder: 部署路径

避免链接失效,参考文献1原文:

How to package your game with commands

Template:Rating This aims to be a quick guide on how to package and distribute your game.

Some points:

  • If you use unreferenced blueprints/objects, you should add them a) using command line or b) by creating a level with all the objects you need to publish in your game (not recomended)
  • Cooking is the proccess of removing unwanted files from your final build
  • You can choose to Pak (like zip) all your content into a single file
  • If you are building a dedicated server, you need to have the compiled version of Unreal or will not work.
  • You will find the RunUAT at UnrealEngine/Engine/Build/BatchFiles
  • Add the command -build if you're using Source Version from Github
  • If the -allmaps flag is used, [AllMaps] with valid +Map=\Game\Maps\Map.umap syntax should be added to DefaultEditor.ini
  • Specific maps can be built (must remove -allmaps flag) using the -maps=Map1+Map2+Map3

Compiling the client (With PAK files):

RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -allmaps -build -stage -pak -archive -archivedirectory="Output Directory"

Cooking the client (With PAK files):

RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -allmaps -NoCompile -stage -pak -archive -archivedirectory="Output Directory"

Compiling the dedicated server (With PAK files):

RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -server -serverplatform=Win64 -noclient -build -stage -pak -archive -archivedirectory="Output Directory"

Cooking the dedicated server (With PAK files):

RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -server -serverplatform=Win64 -noclient -NoCompile -stage -pak -archive -archivedirectory="Output Directory"

猜你喜欢

转载自blog.csdn.net/xlyrh/article/details/89553655