Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/BuildGraph/Tasks/SpawnTask.cs
ben marsh 706acc0477 BuildGraph: Add support for FileReference and DirectoryReference parameters, without having to explicitly parse them.
#rb none
#jira

#ROBOMERGE-SOURCE: CL 4403194 in //UE4/Release-4.21/...
#ROBOMERGE-BOT: RELEASE (Release-4.21 -> Release-Staging-4.21)

[CL 4403195 by ben marsh in Staging-4.21 branch]
2018-09-27 16:51:24 -04:00

102 lines
2.7 KiB
C#

// Copyright 1998-2018 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;
using System.Xml;
using Tools.DotNETCommon;
using UnrealBuildTool;
namespace BuildGraph.Tasks
{
/// <summary>
/// Parameters for a spawn task
/// </summary>
public class SpawnTaskParameters
{
/// <summary>
/// Executable to spawn
/// </summary>
[TaskParameter]
public FileReference Exe;
/// <summary>
/// Arguments for the newly created process
/// </summary>
[TaskParameter(Optional = true)]
public string Arguments;
/// <summary>
/// The minimum exit code which is treated as an error.
/// </summary>
[TaskParameter(Optional = true)]
public int ErrorLevel = 1;
}
/// <summary>
/// Spawns an external executable and waits for it to complete.
/// </summary>
[TaskElement("Spawn", typeof(SpawnTaskParameters))]
public class SpawnTask : CustomTask
{
/// <summary>
/// Parameters for this task
/// </summary>
SpawnTaskParameters Parameters;
/// <summary>
/// Construct a spawn task
/// </summary>
/// <param name="InParameters">Parameters for the task</param>
public SpawnTask(SpawnTaskParameters InParameters)
{
Parameters = InParameters;
}
/// <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>
public override void Execute(JobContext Job, HashSet<FileReference> BuildProducts, Dictionary<string, HashSet<FileReference>> TagNameToFileSet)
{
IProcessResult Result = CommandUtils.Run(Parameters.Exe.FullName, Parameters.Arguments);
if(Result.ExitCode < 0 || Result.ExitCode >= Parameters.ErrorLevel)
{
throw new AutomationException("{0} terminated with an exit code indicating an error ({1})", Path.GetFileName(Parameters.Exe.FullName), Result.ExitCode);
}
}
/// <summary>
/// Output this task out to an XML writer.
/// </summary>
public override void Write(XmlWriter Writer)
{
Write(Writer, Parameters);
}
/// <summary>
/// Find all the tags which are used as inputs to this task
/// </summary>
/// <returns>The tag names which are read by this task</returns>
public override IEnumerable<string> FindConsumedTagNames()
{
yield break;
}
/// <summary>
/// Find all the tags which are modified by this task
/// </summary>
/// <returns>The tag names which are modified by this task</returns>
public override IEnumerable<string> FindProducedTagNames()
{
yield break;
}
}
}