using EpicGames.MCP.Automation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using UnrealBuildTool;
namespace AutomationTool.Tasks
{
///
/// Parameters for a task which merges two chunked builds together
///
public class MergeTaskParameters
{
///
/// The application name
///
[TaskParameter]
public string AppName;
///
/// The initial build version
///
[TaskParameter]
public string BaseVersion;
///
/// The additional files to merge in
///
[TaskParameter]
public string PatchVersion;
///
/// The new build version
///
[TaskParameter]
public string FinalVersion;
///
/// The platform to build for
///
[TaskParameter]
public MCPPlatform Platform;
///
/// Full path to the CloudDir where chunks and manifests should be staged.
///
[TaskParameter]
public string CloudDir;
}
///
/// Implements a task which merges two chunked builds together
///
[TaskElement("Merge", typeof(MergeTaskParameters))]
public class MergeTask : CustomTask
{
///
/// Parameters for this task
///
MergeTaskParameters Parameters;
///
/// Construct a new CommandTask.
///
/// Parameters for this task
public MergeTask(MergeTaskParameters InParameters)
{
Parameters = InParameters;
}
///
/// Execute the task.
///
/// Information about the current job
/// Set of build products produced by this node.
/// Mapping from tag names to the set of files they include
/// True if the task succeeded
public override bool Execute(JobContext Job, HashSet BuildProducts, Dictionary> TagNameToFileSet)
{
// Get the cloud directory
DirectoryReference CloudDir = ResolveDirectory(Parameters.CloudDir);
// Set the patch generation options
BuildPatchToolBase.ManifestMergeOptions Options = new BuildPatchToolBase.ManifestMergeOptions();
Options.ManifestA = FileReference.Combine(CloudDir, String.Format("{0}{1}-{2}.manifest", Parameters.AppName, Parameters.BaseVersion, Parameters.Platform)).FullName;
Options.ManifestB = FileReference.Combine(CloudDir, String.Format("{0}{1}-{2}.manifest", Parameters.AppName, Parameters.PatchVersion, Parameters.Platform)).FullName;
Options.ManifestC = FileReference.Combine(CloudDir, String.Format("{0}{1}-{2}.manifest", Parameters.AppName, Parameters.FinalVersion, Parameters.Platform)).FullName;
Options.BuildVersion = String.Format("{0}-{1}", Parameters.FinalVersion, Parameters.Platform);
// Run the chunking
BuildPatchToolBase.Get().Execute(Options);
return true;
}
///
/// Output this task out to an XML writer.
///
public override void Write(XmlWriter Writer)
{
Write(Writer, Parameters);
}
///
/// Find all the tags which are used as inputs to this task
///
/// The tag names which are read by this task
public override IEnumerable FindConsumedTagNames()
{
yield break;
}
///
/// Find all the tags which are modified by this task
///
/// The tag names which are modified by this task
public override IEnumerable FindProducedTagNames()
{
yield break;
}
}
}