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;
|
2020-12-21 23:07:37 -04:00
|
|
|
|
using EpicGames.Core;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
using UnrealBuildTool;
|
2022-07-22 00:56:39 -04:00
|
|
|
|
using UnrealBuildBase;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
|
|
|
|
|
namespace AutomationTool.Benchmark
|
|
|
|
|
|
{
|
|
|
|
|
|
class BenchmarkSingleCompileTask : BenchmarkBuildTask
|
|
|
|
|
|
{
|
2022-07-22 00:56:39 -04:00
|
|
|
|
FileReference SourceFile = null;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
|
2022-07-22 00:56:39 -04:00
|
|
|
|
public BenchmarkSingleCompileTask(FileReference InProjectFile, string InTarget, UnrealTargetPlatform InPlatform, XGETaskOptions InXgeOption)
|
|
|
|
|
|
: base(InProjectFile, InTarget, InPlatform, InXgeOption, "", 0)
|
2020-02-18 17:19:54 -05:00
|
|
|
|
{
|
2022-07-22 00:56:39 -04:00
|
|
|
|
string ModuleName = InProjectFile == null ? "Unreal" : InProjectFile.GetFileNameWithoutAnyExtensions();
|
|
|
|
|
|
|
|
|
|
|
|
TaskName = string.Format("{0} Incremental {1} {2}", ModuleName, InTarget, InPlatform);
|
|
|
|
|
|
|
|
|
|
|
|
string ProjectName = null;
|
|
|
|
|
|
|
|
|
|
|
|
// Try to find a source file in the project
|
|
|
|
|
|
if (InProjectFile != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
ProjectName = InProjectFile.GetFileNameWithoutAnyExtensions();
|
|
|
|
|
|
DirectoryReference SourceDir = DirectoryReference.Combine(InProjectFile.Directory, "Source", ProjectName);
|
|
|
|
|
|
|
|
|
|
|
|
if (DirectoryReference.Exists(SourceDir))
|
|
|
|
|
|
{
|
|
|
|
|
|
var Files = DirectoryReference.EnumerateFiles(SourceDir, "*.cpp", System.IO.SearchOption.AllDirectories);
|
|
|
|
|
|
SourceFile = Files.FirstOrDefault();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if we didn't, use an engine one
|
|
|
|
|
|
if (SourceFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (InProjectFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
ProjectName = "UnrealEngine";
|
|
|
|
|
|
}
|
|
|
|
|
|
SourceFile = FileReference.Combine(Unreal.EngineDirectory, "Source/Runtime/Engine/Private/UnrealEngine.cpp");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Log.TraceVerbose("Will compile {0} for single-file compilation test for {1}", SourceFile, ProjectName);
|
2020-02-18 17:19:54 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool PerformPrequisites()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!base.PerformPrequisites())
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FileInfo Fi = SourceFile.ToFileInfo();
|
|
|
|
|
|
|
|
|
|
|
|
bool ReadOnly = Fi.IsReadOnly;
|
|
|
|
|
|
|
|
|
|
|
|
if (ReadOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
Fi.IsReadOnly = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Fi.LastWriteTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
if (ReadOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
Fi.IsReadOnly = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-22 00:56:39 -04:00
|
|
|
|
return true;
|
2020-02-18 17:19:54 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-07-22 00:56:39 -04:00
|
|
|
|
|