// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Xml; using Tools.DotNETCommon; using UnrealBuildTool; namespace AutomationTool { /// /// Parameters for a task that uploads symbols to a symbol server /// public class SymStoreTaskParameters { /// /// The platform toolchain required to handle symbol files. /// [TaskParameter] public UnrealTargetPlatform Platform; /// /// List of output files. PDBs will be extracted from this list. /// [TaskParameter] public string Files; /// /// Output directory for the compressed symbols. /// [TaskParameter] public string StoreDir; /// /// Name of the product for the symbol store records. /// [TaskParameter] public string Product; /// /// BuildVersion associated with these symbols. Used for cleanup in AgeStore by matching this version against a directory name in a build share /// [TaskParameter(Optional = true)] public string BuildVersion; } /// /// Task which strips symbols from a set of files /// [TaskElement("SymStore", typeof(SymStoreTaskParameters))] public class SymStoreTask : CustomTask { /// /// Parameters for this task /// SymStoreTaskParameters Parameters; /// /// Construct a spawn task /// /// Parameters for the task public SymStoreTask(SymStoreTaskParameters 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 public override void Execute(JobContext Job, HashSet BuildProducts, Dictionary> TagNameToFileSet) { // Find the matching files List Files = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet).ToList(); // Get the symbol store directory DirectoryReference StoreDir = ResolveDirectory(Parameters.StoreDir); // Take the lock before accessing the symbol server, if required by the platform Platform TargetPlatform = Platform.GetPlatform(Parameters.Platform); CommandUtils.OptionallyTakeLock(TargetPlatform.SymbolServerRequiresLock, StoreDir, TimeSpan.FromMinutes(60), () => { if (!TargetPlatform.PublishSymbols(StoreDir, Files, Parameters.Product, Parameters.BuildVersion)) { throw new AutomationException("Failure publishing symbol files."); } }); } /// /// 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() { return FindTagNamesFromFilespec(Parameters.Files); } /// /// 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; } } }