using AutomationTool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using UnrealBuildTool;
namespace BuildGraph.Tasks
{
///
/// Parameters for a task that strips symbols from a set of files
///
public class SignTaskParameters
{
///
/// List of file specifications separated by semicolons (eg. *.cpp;Engine/.../*.bat), or the name of a tag set
///
[TaskParameter]
public string Files;
///
/// Tag to be applied to build products of this task
///
[TaskParameter(Optional = true, ValidationType = TaskParameterValidationType.Tag)]
public string Tag;
}
///
/// Task which strips symbols from a set of files
///
[TaskElement("Sign", typeof(SignTaskParameters))]
public class SignTask : CustomTask
{
///
/// Parameters for this task
///
SignTaskParameters Parameters;
///
/// Construct a spawn task
///
/// Parameters for the task
public SignTask(SignTaskParameters 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)
{
// Find the matching files
FileReference[] Files = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet).OrderBy(x => x.FullName).ToArray();
// Sign all the files
CodeSign.SignMultipleFilesIfEXEOrDLL(Files.Select(x => x.FullName).ToList(), true);
// Apply the optional tag to the build products
if(!String.IsNullOrEmpty(Parameters.Tag))
{
FindOrAddTagSet(TagNameToFileSet, Parameters.Tag).UnionWith(Files);
}
// Add them to the list of build products
BuildProducts.UnionWith(Files);
return true;
}
///
/// Output this task out to an XML writer.
///
public override void Write(XmlWriter Writer)
{
Write(Writer, Parameters);
}
}
}