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 spawn task /// public class SpawnTaskParameters { /// /// Executable to spawn /// [TaskParameter] public string Exe; /// /// Arguments for the newly created process /// [TaskParameter(Optional = true)] public string Arguments; /// /// The minimum exit code which is treated as an error. /// [TaskParameter(Optional = true)] public int ErrorLevel = 1; } /// /// Task which spawns an external executable /// [TaskElement("Spawn", typeof(SpawnTaskParameters))] public class SpawnTask : CustomTask { /// /// Parameters for this task /// SpawnTaskParameters Parameters; /// /// Construct a spawn task /// /// Parameters for the task public SpawnTask(SpawnTaskParameters 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) { ProcessResult Result = CommandUtils.Run(Parameters.Exe, Parameters.Arguments); return Result.ExitCode >= 0 && Result.ExitCode < Parameters.ErrorLevel; } /// /// 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; } } }