Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/Scripts/CookCommand.Automation.cs
Ben Zeigler 67566bb0f2 Merging changes to UAT from UE4-Fortnite branch, up to CL #2256868:
Add BuildOnlyPlatforms_MonolithicOnly to the RulesCompiler, to specify platforms that we want to compile but not cook
Add concept of "Dependent platform" to UAT, where the cooked data comes from a source platform, and is duplicated at stage time
Updated brutal submit to handle the same changes already being submitted during a build.
Brutal submit now considers it as success when it attempts to reconcile with latest in P4 and finds no files are different in its workspace.
Fix formatting on automation.cs files to avoid future integration issues, unify as tabs-as-tabs instead of spaces

#codereview kellan.carr

[CL 2261070 by Ben Zeigler in Main branch]
2014-08-18 13:29:39 -04:00

125 lines
3.5 KiB
C#

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Reflection;
using System.Linq;
using AutomationTool;
using UnrealBuildTool;
/// <summary>
/// Helper command used for cooking.
/// </summary>
/// <remarks>
/// Command line parameters used by this command:
/// -clean
/// </remarks>
public partial class Project : CommandUtils
{
#region Cook Command
public static void Cook(ProjectParams Params)
{
if (!Params.Cook || Params.SkipCook)
{
return;
}
Params.ValidateAndLog();
string UE4EditorExe = HostPlatform.Current.GetUE4ExePath(Params.UE4Exe);
if (!FileExists(UE4EditorExe))
{
throw new AutomationException("Missing " + UE4EditorExe + " executable. Needs to be built first.");
}
var PlatformsToCook = new HashSet<string>();
if (!Params.NoClient)
{
foreach (var ClientPlatform in Params.ClientTargetPlatforms)
{
// Use the data platform, sometimes we will copy another platform's data
var DataPlatform = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(false, Params.HasDedicatedServerAndClient, Params.CookFlavor));
}
}
if (Params.DedicatedServer)
{
foreach (var ServerPlatform in Params.ServerTargetPlatforms)
{
// Use the data platform, sometimes we will copy another platform's data
var DataPlatform = Params.GetCookedDataPlatformForServerTarget(ServerPlatform);
PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(true, false, Params.CookFlavor));
}
}
if (Params.Clean.HasValue && Params.Clean.Value && !Params.IterativeCooking)
{
Log("Cleaning cooked data.");
CleanupCookedData(PlatformsToCook.ToList(), Params);
}
// cook the set of maps, or the run map, or nothing
string[] Maps = null;
if (Params.HasMapsToCook)
{
Maps = Params.MapsToCook.ToArray();
}
string[] Dirs = null;
if (Params.HasDirectoriesToCook)
{
Dirs = Params.DirectoriesToCook.ToArray();
}
string[] Cultures = null;
if (Params.HasCulturesToCook)
{
Cultures = Params.CulturesToCook.ToArray();
}
try
{
var CommandletParams = "-buildmachine -Unversioned -fileopenlog";
if (Params.UseDebugParamForEditorExe)
{
CommandletParams += " -debug";
}
if (Params.Manifests)
{
CommandletParams += " -manifests";
}
if (Params.IterativeCooking)
{
CommandletParams += " -iterate";
}
CookCommandlet(Params.RawProjectPath, Params.UE4Exe, Maps, Dirs, Cultures, CombineCommandletParams(PlatformsToCook.ToArray()), CommandletParams);
}
catch (Exception Ex)
{
// Delete cooked data (if any) as it may be incomplete / corrupted.
Log("Cook failed. Deleting cooked data.");
CleanupCookedData(PlatformsToCook.ToList(), Params);
AutomationTool.ErrorReporter.Error("Cook failed.", (int)AutomationTool.ErrorCodes.Error_UnknownCookFailure);
throw Ex;
}
}
private static void CleanupCookedData(List<string> PlatformsToCook, ProjectParams Params)
{
var ProjectPath = Path.GetFullPath(Params.RawProjectPath);
var CookedSandboxesPath = CombinePaths(GetDirectoryName(ProjectPath), "Saved", "Cooked");
var CleanDirs = new string[PlatformsToCook.Count];
for (int DirIndex = 0; DirIndex < CleanDirs.Length; ++DirIndex)
{
CleanDirs[DirIndex] = CombinePaths(CookedSandboxesPath, PlatformsToCook[DirIndex]);
}
const bool bQuiet = true;
DeleteDirectory(bQuiet, CleanDirs);
}
#endregion
}