Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/BuildGraph/Tasks/CompileTask.cs
Ben Marsh 6af6c038ea Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 2982165)
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2963214 on 2016/05/02 by Ben.Marsh

	BuildGraph: Allow specifying optional dependencies for a node, indicating that the build products from an upstream node are desired, but should not block the node from running.

Change 2972295 on 2016/05/10 by Ben.Marsh

	EC: Remove spacing in notification emails to reduce size, and help prevent gmail from truncating messages. Also allow mailing notification emails when doing a dry run, and reading stream settings from another branch.

Change 2976096 on 2016/05/12 by Ben.Marsh

	EC: Store properties for the last succeeded builds, including the list of users that were notified about it.

Change 2976390 on 2016/05/12 by Ben.Marsh

	EC: Add a separate line to the notification email summary with a link to edit settings, and pass the missing ec-update parameter to set the last build status.

Change 2976441 on 2016/05/12 by Ben.Marsh

	UAT: Remove log file copy on builders after UAT failure. This is done outside the EC step that originally did it now.

Change 2976456 on 2016/05/12 by Ben.Marsh

	BuildGraph: Catch exceptions thrown by child processes failing when building or running UAT commands, and return failure normally without dumping callstacks.

Change 2978440 on 2016/05/16 by Ben.Marsh

	EC: Age out entries from the "latest builds" list after a week. There's no obvious way to tell if a node has been removed, but a periodic cleanup should keep the build notifications list in check.

Change 2979446 on 2016/05/16 by Ben.Marsh

	Rename ambiguous headers which exist with the same name in different paths.

Change 2979839 on 2016/05/16 by Ben.Marsh

	UE4: Renaming HTML5 SocketSubsystem files to eliminate ambiguities.

Change 2979852 on 2016/05/16 by Ben.Marsh

	UE4: Use explicit relative paths for public headers in PortalServiceInterfaces modules which do not have unique names

Change 2980113 on 2016/05/17 by Ben.Marsh

	UE4: Fix include paths for HTML5 SocketSubsystem files.

Change 2980117 on 2016/05/17 by Ben.Marsh

	UE4: Remove reference to private PCH from Oculus common code.

Change 2980186 on 2016/05/17 by Ben.Marsh

	UAT: Add a -StopOnErrors parameter to UE4Build, which is propagated to XGE.

Change 2980879 on 2016/05/17 by Ben.Marsh

	UE4: Fixup Lightmass to use LightmassPCH.h rather than stdafx.h

Change 2981117 on 2016/05/17 by Ben.Marsh

	Portal: Use a unique name for the Portal PCH, rather than just calling it PrivatePCH.h

Change 2981839 on 2016/05/18 by Ben.Marsh

	Replace ambiguous D3D11/D3D12 includes with direct includes for the current platform.

#lockdown Nick.Penwarden

[CL 2982178 by Ben Marsh in Main branch]
2016-05-18 13:26:45 -04:00

169 lines
5.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnrealBuildTool;
using AutomationTool;
using System.Xml;
namespace AutomationTool
{
/// <summary>
/// Parameters for a compile task
/// </summary>
public class CompileTaskParameters
{
/// <summary>
/// The target to compile
/// </summary>
[TaskParameter]
public string Target;
/// <summary>
/// The configuration to compile
/// </summary>
[TaskParameter]
public UnrealTargetConfiguration Configuration;
/// <summary>
/// The platform to compile for
/// </summary>
[TaskParameter]
public UnrealTargetPlatform Platform;
/// <summary>
/// Additional arguments for UnrealBuildTool
/// </summary>
[TaskParameter(Optional = true)]
public string Arguments;
/// <summary>
/// Tag to be applied to build products of this task
/// </summary>
[TaskParameter(Optional = true, ValidationType = TaskParameterValidationType.Tag)]
public string Tag;
}
/// <summary>
/// Task which compiles a target with UnrealBuildTool
/// </summary>
[TaskElement("Compile", typeof(CompileTaskParameters))]
public class CompileTask : CustomTask
{
/// <summary>
/// List of targets to compile. As well as the target specifically added for this task, additional compile tasks may be merged with it.
/// </summary>
List<UE4Build.BuildTarget> Targets = new List<UE4Build.BuildTarget>();
/// <summary>
/// Mapping of receipt filename to its corresponding tag name
/// </summary>
Dictionary<UE4Build.BuildTarget, string> TargetToTagName = new Dictionary<UE4Build.BuildTarget,string>();
/// <summary>
/// Construct a compile task
/// </summary>
/// <param name="InParameters">Parameters for this task</param>
public CompileTask(CompileTaskParameters Parameters)
{
UE4Build.BuildTarget Target = new UE4Build.BuildTarget { TargetName = Parameters.Target, Platform = Parameters.Platform, Config = Parameters.Configuration, UBTArgs = "-nobuilduht " + (Parameters.Arguments ?? "") };
if(!String.IsNullOrEmpty(Parameters.Tag))
{
TargetToTagName.Add(Target, Parameters.Tag);
}
Targets.Add(Target);
}
/// <summary>
/// Allow this task to merge with other tasks within the same node. This can be useful to allow tasks to execute in parallel and reduce overheads.
/// </summary>
/// <param name="OtherTasks">Other tasks that this task can merge with. If a merge takes place, the other tasks should be removed from the list.</param>
public override void Merge(List<CustomTask> OtherTasks)
{
for (int Idx = 0; Idx < OtherTasks.Count; Idx++)
{
CompileTask OtherCompileTask = OtherTasks[Idx] as CompileTask;
if (OtherCompileTask != null)
{
Targets.AddRange(OtherCompileTask.Targets);
foreach(KeyValuePair<UE4Build.BuildTarget, string> TargetTagName in OtherCompileTask.TargetToTagName)
{
TargetToTagName.Add(TargetTagName.Key, TargetTagName.Value);
}
OtherTasks.RemoveAt(Idx);
}
}
}
/// <summary>
/// Execute the task.
/// </summary>
/// <param name="Job">Information about the current job</param>
/// <param name="BuildProducts">Set of build products produced by this node.</param>
/// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
/// <returns>True if the task succeeded</returns>
public override bool Execute(JobContext Job, HashSet<FileReference> BuildProducts, Dictionary<string, HashSet<FileReference>> TagNameToFileSet)
{
// Create the agenda
UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();
Agenda.Targets.AddRange(Targets);
// Build everything
Dictionary<UE4Build.BuildTarget, BuildManifest> TargetToManifest = new Dictionary<UE4Build.BuildTarget,BuildManifest>();
UE4Build Builder = new UE4Build(Job.OwnerCommand);
try
{
Builder.Build(Agenda, InDeleteBuildProducts: null, InUpdateVersionFiles: false, InForceNoXGE: false, InUseParallelExecutor: true, InTargetToManifest: TargetToManifest);
}
catch (CommandUtils.CommandFailedException)
{
return false;
}
UE4Build.CheckBuildProducts(Builder.BuildProductFiles);
// Tag all the outputs
foreach(KeyValuePair<UE4Build.BuildTarget, string> TargetTagName in TargetToTagName)
{
BuildManifest Manifest;
if(!TargetToManifest.TryGetValue(TargetTagName.Key, out Manifest))
{
throw new AutomationException("Missing manifest for target {0} {1} {2}", TargetTagName.Key.TargetName, TargetTagName.Key.Platform, TargetTagName.Key.Config);
}
HashSet<FileReference> FileSet = FindOrAddTagSet(TagNameToFileSet, TargetTagName.Value);
FileSet.UnionWith(Manifest.BuildProducts.Select(x => new FileReference(x)));
FileSet.UnionWith(Manifest.LibraryBuildProducts.Select(x => new FileReference(x)));
}
// Add everything to the list of build products
BuildProducts.UnionWith(Builder.BuildProductFiles.Select(x => new FileReference(x)));
BuildProducts.UnionWith(Builder.LibraryBuildProductFiles.Select(x => new FileReference(x)));
return true;
}
/// <summary>
/// Output this task out to an XML writer.
/// </summary>
public override void Write(XmlWriter Writer)
{
foreach (UE4Build.BuildTarget Target in Targets)
{
CompileTaskParameters Parameters = new CompileTaskParameters();
Parameters.Target = Target.TargetName;
Parameters.Platform = Target.Platform;
Parameters.Configuration = Target.Config;
Parameters.Arguments = Target.UBTArgs;
string TagName;
if (TargetToTagName.TryGetValue(Target, out TagName))
{
Parameters.Tag = TagName;
}
Write(Writer, Parameters);
}
}
}
}