// Copyright Epic Games, Inc. All Rights Reserved.
using System.Collections.Generic;
using System.Linq;
using AutomationTool;
using UnrealBuildTool;
using System.Xml;
using EpicGames.Core;
using UnrealBuildBase;
using EpicGames.BuildGraph;
using System.Runtime.Versioning;
namespace Win.Automation
{
///
/// Parameters for a task that uploads symbols to a symbol server
///
public class SrcSrvTaskParameters
{
///
/// List of output files. PDBs will be extracted from this list.
///
[TaskParameter]
public string BinaryFiles;
///
/// List of source files to index and embed into the PDBs.
///
[TaskParameter]
public string SourceFiles;
///
/// Branch to base all the depot source files from
///
[TaskParameter]
public string Branch;
///
/// Changelist to sync files from
///
[TaskParameter]
public int Change;
}
///
/// Task which strips symbols from a set of files
/// Note that this task only supports source indexing for Windows-like platforms.
/// SymStore can be considered a generalization of this task because in addition to uploading symbols
/// it can also index sources and supports consoles as well (any missing platform that supports
/// source indexing in general may add support for it by extending PublishSymbols).
/// Check SymStoreTaskParameters.IndexSources/SourceFiles/Branch/Change
///
[TaskElement("SrcSrv", typeof(SrcSrvTaskParameters))]
public class SrcSrvTask : CustomTask
{
///
/// Parameters for this task
///
SrcSrvTaskParameters Parameters;
///
/// Construct a spawn task
///
/// Parameters for the task
public SrcSrvTask(SrcSrvTaskParameters 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
[SupportedOSPlatform("windows")]
public override void Execute(JobContext Job, HashSet BuildProducts, Dictionary> TagNameToFileSet)
{
FileReference[] BinaryFiles = ResolveFilespec(Unreal.RootDirectory, Parameters.BinaryFiles, TagNameToFileSet).ToArray();
FileReference[] SourceFiles = ResolveFilespec(Unreal.RootDirectory, Parameters.SourceFiles, TagNameToFileSet).ToArray();
Execute(BinaryFiles, SourceFiles, Parameters.Branch, Parameters.Change);
}
[SupportedOSPlatform("windows")]
internal static void Execute(FileReference[] BinaryFiles, FileReference[] SourceFiles, string Branch, int Change)
{
IEnumerable PdbFiles = BinaryFiles.Where(x => x.HasExtension(".pdb"));
Win64Platform WindowsPlatform = Platform.GetPlatform(UnrealTargetPlatform.Win64) as Win64Platform;
WindowsPlatform.AddSourceIndexToSymbols(PdbFiles, SourceFiles, Branch, Change);
}
///
/// 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()
{
foreach(string TagName in FindTagNamesFromFilespec(Parameters.BinaryFiles))
{
yield return TagName;
}
foreach(string TagName in FindTagNamesFromFilespec(Parameters.SourceFiles))
{
yield return TagName;
}
}
///
/// 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;
}
}
public static partial class BgStateExtensions
{
///
/// Uploads symbols to a symbol server
///
///
/// List of output files. PDBs will be extracted from this list.
/// List of source files to index and embed into the PDBs.
/// Branch to base all the depot source files from.
/// Changelist to sync files from.
///
[SupportedOSPlatform("windows")]
public static void SrcSrv(this BgContext State, HashSet BinaryFiles, HashSet SourceFiles, string Branch, int Change)
{
SrcSrvTask.Execute(BinaryFiles.ToArray(), SourceFiles.ToArray(), Branch, Change);
}
}
}