Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/BuildGraph/Tasks/LogTask.cs
jonathan adamczewski 64c210d294 AutomationTool, BuildUtilities:
UnrealBuild -> Unreal for EngineDirectory, RootDirectory, IsEngineInstalled, UnrealBuildToolPath
Remove CommandUtils EngineDirectory, RootDirectory, IsEngineInstalled - use equvalents from UnrealBuildBase.Unreal

#jira none

#ROBOMERGE-SOURCE: CL 16648181 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v833-16641396)

[CL 16648203 by jonathan adamczewski in ue5-release-engine-test branch]
2021-06-11 18:21:35 -04:00

120 lines
3.2 KiB
C#

// Copyright 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 EpicGames.Core;
using UnrealBuildTool;
using UnrealBuildBase;
namespace BuildGraph.Tasks
{
/// <summary>
/// Parameters for the log task
/// </summary>
public class LogTaskParameters
{
/// <summary>
/// Message to print out.
/// </summary>
[TaskParameter(Optional = true)]
public string Message;
/// <summary>
/// If specified, causes the given list of files to be printed after the given message.
/// </summary>
[TaskParameter(Optional = true, ValidationType = TaskParameterValidationType.FileSpec)]
public string Files;
/// <summary>
/// If specified, causes the contents of the given files to be printed out.
/// </summary>
[TaskParameter(Optional = true)]
public bool IncludeContents;
}
/// <summary>
/// Print a message (and other optional diagnostic information) to the output log.
/// </summary>
[TaskElement("Log", typeof(LogTaskParameters))]
public class LogTask : CustomTask
{
/// <summary>
/// Parameters for the task
/// </summary>
LogTaskParameters Parameters;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="InParameters">Parameters for the task</param>
public LogTask(LogTaskParameters 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)
{
// Print the message
if(!String.IsNullOrEmpty(Parameters.Message))
{
CommandUtils.LogInformation(Parameters.Message);
}
// Print the contents of the given tag, if specified
if(!String.IsNullOrEmpty(Parameters.Files))
{
HashSet<FileReference> Files = ResolveFilespec(Unreal.RootDirectory, Parameters.Files, TagNameToFileSet);
foreach(FileReference File in Files.OrderBy(x => x.FullName))
{
CommandUtils.LogInformation(" {0}", File.FullName);
if(Parameters.IncludeContents)
{
foreach(string Line in System.IO.File.ReadAllLines(File.FullName))
{
CommandUtils.LogInformation(" {0}", Line);
}
}
}
}
}
/// <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()
{
return FindTagNamesFromFilespec(Parameters.Files);
}
/// <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;
}
}
}