UAT build error when c++ module contains only unreferenced APIs

Repro:

  • UE4.19.1 (built from source)

  • Create a default BP ThirdPerson project. Load in Editor. Confirm you can play. Quit.

  • Build from Command line for Win64 Release or Development, for example…
    “%_UnrealAutomationToolExe%” BuildCookRun -noP4 -project=%_ProjectFile% -platform=%_BuildTarget% -clientconfig=%_BuildConfiguration% -serverconfig=%_BuildConfiguration% -cook -allmaps -build -stage -pak -archivedirectory=%_AppLayoutRoot%

RESULT: Build Success

  • Re-open the project and create a simple C++ class. Build/run in the editor. Close the Editor.

  • Clean and build from Command line (same as above)

RESULT: Build failure…

ERROR: Cook failed.
(see D:\Root\Projects\Tools\UE4\Engine\Programs\AutomationTool\Saved\Logs\UAT_Log.txt for full exception trace)

CommandletException: Editor terminated with exit code 1 while running Cook for D:\Root\Projects\Projects\TestBuild2\Game\TestBuild2.uproject; see log D:\Root\Projects\Tools\UE4\Engine\Programs\AutomationTool\Saved\Logs\Cook-2018.04.23-14.40.42.txt
at AutomationTool.CommandUtils.RunCommandlet(FileReference ProjectName, String UE4Exe, String Commandlet, String Parameters) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\AutomationUtils\CommandletUtils.cs:line 372
at AutomationTool.CommandUtils.CookCommandlet(FileReference ProjectName, String UE4Exe, String[] Maps, String[] Dirs, String InternationalizationPreset, String[] CulturesToCook, String TargetPlatform, String Parameters) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\AutomationUtils\CommandletUtils.cs:line 94
at Project.Cook(ProjectParams Params) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\Scripts\CookCommand.Automation.cs:line 257
Wrapped by AutomationException: Cook failed.
at Project.Cook(ProjectParams Params) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\Scripts\CookCommand.Automation.cs:line 271
at BuildCookRun.DoBuildCookRun(ProjectParams Params) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 209
at BuildCookRun.ExecuteBuild() in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 41
at AutomationTool.BuildCommand.Execute() in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 100
at AutomationTool.Automation.Execute(List1 CommandsToExecute, Dictionary2 Commands) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 557
at AutomationTool.Automation.Process(String[] Arguments) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 527
at AutomationTool.Program.MainProc(Object Param) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\Program.cs:line 132
at AutomationTool.InternalUtils.RunSingleInstance(Func`2 Main, Object Param) in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\AutomationUtils\Utils.cs:line 712
at AutomationTool.Program.Main() in D:\Root\Tools\UE4\Engine\Source\Programs\AutomationTool\Program.cs:line 62

AutomationTool exiting with ExitCode=25 (Error_UnknownCookFailure)
App Build Failed (ERRORLEVEL = 25). See D:\Builds\Projects\TestBuild2\TestBuild2_20180423.1\Logs\AppLayout_Debug_Win64.log for details.
Build Failed (ERRORLEVEL = 25)

Looking up the log, we can see that our default generated Editor module wasn’t built…

LogInit: Warning: Incompatible or missing module: UE4Editor-TestBuild2.dll

  • Re-open the project and create an Actor-derived C++ class and create an instance in the main scene (now it is used/referenced). Build/run in the editor. Close the Editor.

  • Clean and build from Command line (same as above)

RESULT: Build Success

Theory: API stripping during cook is ejecting the game modules due to unreferenced code, but the module is still being included in the bill of materials (BoM) for the layout. Feels like a bug.

Request: Please point me at documentation WRT cooking and API stripping rules. Also documentation WRT how to mark C++/Blueprints such that they aren’t rejected by that process.

  • Appreciated