using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using UnrealBuildTool; namespace AutomationTool.Tasks { /// /// Parameters for the version task /// public class SetVersionTaskParameters { /// /// The changelist to set in the version files /// [TaskParameter] public int Change; /// /// The branch string /// [TaskParameter] public string Branch; /// /// Whether to set the IS_LICENSEE_VERSION flag to true /// [TaskParameter(Optional = true)] public bool Licensee; /// /// If set, don't actually write to the files - just return the version files that would be updated. Useful for local builds. /// [TaskParameter(Optional = true)] public bool SkipWrite; /// /// Tag to be applied to build products of this task /// [TaskParameter(Optional = true, ValidationType = TaskParameterValidationType.Tag)] public string Tag; } /// /// Task which updates the version files in the current branch /// [TaskElement("SetVersion", typeof(SetVersionTaskParameters))] public class SetVersionTask : CustomTask { /// /// Parameters for the task /// SetVersionTaskParameters Parameters; /// /// Construct a version task /// /// Parameters for this task public SetVersionTask(SetVersionTaskParameters 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) { // Update the version files List FileNames = UE4Build.StaticUpdateVersionFiles(Parameters.Change, Parameters.Branch, Parameters.Licensee, !Parameters.SkipWrite); List VersionFiles = FileNames.Select(x => new FileReference(x)).ToList(); // Apply the optional tag to them if(!String.IsNullOrEmpty(Parameters.Tag)) { FindOrAddTagSet(TagNameToFileSet, Parameters.Tag).UnionWith(VersionFiles); } // Add them to the list of build products BuildProducts.UnionWith(VersionFiles); return true; } /// /// Output this task out to an XML writer. /// public override void Write(XmlWriter Writer) { Write(Writer, Parameters); } } }