2020-02-18 17:19:54 -05:00
|
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
|
|
using AutomationTool;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Tools.DotNETCommon;
|
|
|
|
|
|
using UnrealBuildTool;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AutomationTool.Benchmark
|
|
|
|
|
|
{
|
2020-03-05 13:50:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkCookTask : BenchmarkEditorTaskBase
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2020-03-05 13:50:48 -05:00
|
|
|
|
string ProjectName;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
FileReference ProjectFile;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
string CookPlatformName;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
EditorTaskOptions Options;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
string CookArgs;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
public BenchmarkCookTask(string InProject, UnrealTargetPlatform InPlatform, EditorTaskOptions InOptions, string InCookArgs)
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
|
|
|
|
|
ProjectName = InProject;
|
|
|
|
|
|
Options = InOptions;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
CookArgs = InCookArgs;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
|
|
|
|
|
ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName);
|
|
|
|
|
|
|
|
|
|
|
|
var PlatformToCookPlatform = new Dictionary<UnrealTargetPlatform, string> {
|
|
|
|
|
|
{ UnrealTargetPlatform.Win64, "WindowsClient" },
|
|
|
|
|
|
{ UnrealTargetPlatform.Mac, "MacClient" },
|
|
|
|
|
|
{ UnrealTargetPlatform.Linux, "LinuxClient" },
|
|
|
|
|
|
{ UnrealTargetPlatform.Android, "Android_ASTCClient" }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CookPlatformName = InPlatform.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
if (PlatformToCookPlatform.ContainsKey(InPlatform))
|
|
|
|
|
|
{
|
|
|
|
|
|
CookPlatformName = PlatformToCookPlatform[InPlatform];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TaskName = string.Format("Cook {0} {1}", InProject, CookPlatformName);
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.NoDDC))
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2020-02-21 13:09:10 -05:00
|
|
|
|
TaskModifiers.Add("noddc");
|
2020-02-18 17:19:54 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.NoShaderDDC))
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2020-02-21 13:09:10 -05:00
|
|
|
|
TaskModifiers.Add("noshaderddc");
|
2020-02-18 17:19:54 -05:00
|
|
|
|
}
|
2020-03-01 14:49:53 -05:00
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.ColdDDC))
|
2020-03-01 14:49:53 -05:00
|
|
|
|
{
|
|
|
|
|
|
TaskModifiers.Add("coldddc");
|
|
|
|
|
|
}
|
2020-03-05 13:50:48 -05:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(CookArgs))
|
|
|
|
|
|
{
|
|
|
|
|
|
TaskModifiers.Add(CookArgs);
|
|
|
|
|
|
}
|
2020-02-18 17:19:54 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool PerformPrequisites()
|
|
|
|
|
|
{
|
|
|
|
|
|
// build editor
|
|
|
|
|
|
BuildTarget Command = new BuildTarget();
|
|
|
|
|
|
Command.ProjectName = ProjectName;
|
|
|
|
|
|
Command.Platforms = BuildHostPlatform.Current.Platform.ToString();
|
|
|
|
|
|
Command.Targets = "Editor";
|
|
|
|
|
|
|
|
|
|
|
|
if (Command.Execute() != ExitCode.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Do a cook to make sure the remote ddc is warm?
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.HotDDC))
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
|
|
|
|
|
// will throw an exception if it fails
|
|
|
|
|
|
CommandUtils.RunCommandlet(ProjectFile, "UE4Editor-Cmd.exe", "Cook", String.Format("-TargetPlatform={0} ", CookPlatformName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.ColdDDC))
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2020-03-05 13:50:48 -05:00
|
|
|
|
DeleteLocalDDC(ProjectFile);
|
2020-02-18 17:19:54 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool PerformTask()
|
|
|
|
|
|
{
|
2020-03-05 13:50:48 -05:00
|
|
|
|
List<string> ExtraArgsList = new List<string>();
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.CookClient))
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2020-03-05 13:50:48 -05:00
|
|
|
|
ExtraArgsList.Add("client");
|
2020-02-18 17:19:54 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.NoShaderDDC))
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2020-03-05 13:50:48 -05:00
|
|
|
|
ExtraArgsList.Add("noshaderddc");
|
2020-02-18 17:19:54 -05:00
|
|
|
|
//ExtraArgs.Add("noxgeshadercompile");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
if (Options.HasFlag(EditorTaskOptions.NoDDC))
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2020-03-05 13:50:48 -05:00
|
|
|
|
ExtraArgsList.Add("ddc=noshared");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string ExtraArgs = "";
|
|
|
|
|
|
|
|
|
|
|
|
if (ExtraArgsList.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
ExtraArgs = "-" + string.Join(" -", ExtraArgsList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (CookArgs.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
ExtraArgs += " " + CookArgs;
|
|
|
|
|
|
}
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
|
|
|
|
|
// will throw an exception if it fails
|
2020-03-05 13:50:48 -05:00
|
|
|
|
CommandUtils.RunCommandlet(ProjectFile, "UE4Editor-Cmd.exe", "Cook", String.Format("-TargetPlatform={0} {1}", CookPlatformName, ExtraArgs));
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|