Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/Scripts/BenchmarkBuild/BenchmarkCookTask.cs
T

143 lines
3.1 KiB
C#
Raw Normal View History

// 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 EpicGames.Core;
using UnrealBuildTool;
2021-06-17 01:49:00 -04:00
using UnrealBuildBase;
namespace AutomationTool.Benchmark
{
2020-03-05 13:50:48 -05:00
class BenchmarkCookTask : BenchmarkEditorTaskBase
{
2022-07-22 00:56:39 -04:00
protected string CookPlatformName;
2022-07-22 00:56:39 -04:00
string CookArgs;
2022-07-22 00:56:39 -04:00
bool CookAsClient;
2022-09-03 11:10:17 -04:00
public override string TaskName
{
get
{
return string.Format("Cook {0}", CookPlatformName);
}
}
2022-07-22 00:56:39 -04:00
public BenchmarkCookTask(ProjectTargetInfo InTargetInfo, ProjectTaskOptions InOptions, bool InSkipBuild)
: base(InTargetInfo, InOptions, InSkipBuild)
{
2022-07-22 00:56:39 -04:00
CookArgs = InOptions.Args;
CookAsClient = InTargetInfo.BuildTargetAsClient;
var PlatformToCookPlatform = new Dictionary<UnrealTargetPlatform, string> {
{ UnrealTargetPlatform.Win64, "WindowsClient" },
{ UnrealTargetPlatform.Mac, "MacClient" },
{ UnrealTargetPlatform.Linux, "LinuxClient" },
{ UnrealTargetPlatform.Android, "Android_ASTCClient" }
};
2022-07-22 00:56:39 -04:00
CookPlatformName = InTargetInfo.TargetPlatform.ToString();
2022-07-22 00:56:39 -04:00
if (PlatformToCookPlatform.ContainsKey(InTargetInfo.TargetPlatform))
{
2022-07-22 00:56:39 -04:00
CookPlatformName = PlatformToCookPlatform[InTargetInfo.TargetPlatform];
}
2022-07-22 00:12:59 -04:00
}
2022-07-22 00:56:39 -04:00
protected override string GetEditorTaskArgs()
2022-07-22 00:12:59 -04:00
{
2022-07-22 00:56:39 -04:00
string Arguments = "";
2022-07-22 00:12:59 -04:00
2022-07-22 00:13:12 -04:00
if (CookAsClient)
{
2022-07-22 00:56:39 -04:00
Arguments += " -client";
2022-07-22 00:13:12 -04:00
}
if (CookArgs.Length > 0)
{
2022-07-22 00:56:39 -04:00
Arguments += " " + CookArgs;
2022-07-22 00:13:12 -04:00
}
2022-07-22 00:56:39 -04:00
return Arguments;
}
2022-07-22 00:13:12 -04:00
2022-07-22 00:56:39 -04:00
protected override bool PerformTask()
{
string Arguments = GetBasicEditorCommandLine(false);
// will throw an exception if it fails
CommandUtils.RunCommandlet(ProjectTarget.ProjectFile, "UnrealEditor-Cmd.exe", "Cook", String.Format("-TargetPlatform={0} {1}", CookPlatformName, Arguments));
2022-07-22 00:13:12 -04:00
return true;
2022-07-22 00:12:59 -04:00
}
}
2022-07-22 00:56:39 -04:00
/// <summary>
/// Iterative cooking test
/// </summary>
class BenchmarkIterativeCookTask : BenchmarkCookTask
{
public BenchmarkIterativeCookTask(ProjectTargetInfo InTargetInfo, ProjectTaskOptions InOptions, bool InSkipBuild)
: base(InTargetInfo, InOptions, InSkipBuild)
{
2022-09-03 11:10:17 -04:00
}
public override string TaskName
{
get
{
return string.Format("Iterative Cook {0}", CookPlatformName);
}
2022-07-22 00:56:39 -04:00
}
protected override bool PerformPrequisites()
{
if (!base.PerformPrequisites())
{
return false;
}
DirectoryReference ContentDir = DirectoryReference.Combine(ProjectTarget.ProjectFile.Directory, "Content");
var Files = DirectoryReference.EnumerateFiles(ContentDir, "*.uasset", System.IO.SearchOption.AllDirectories);
var AssetFile = Files.FirstOrDefault();
if (AssetFile == null)
{
Log.TraceError("Could not find asset file to touch under {0}", ContentDir);
return false;
}
FileInfo Fi = AssetFile.ToFileInfo();
bool ReadOnly = Fi.IsReadOnly;
if (ReadOnly)
{
Fi.IsReadOnly = false;
}
Fi.LastWriteTime = DateTime.Now;
if (ReadOnly)
{
Fi.IsReadOnly = true;
}
return true;
}
protected override string GetEditorTaskArgs()
{
string Args = base.GetEditorTaskArgs();
Args += " -iterate";
return Args;
}
}
}