2018-12-14 13:41:00 -05:00
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
2016-12-08 08:52:44 -05:00
using System ;
2016-03-13 18:53:13 -04:00
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
2016-04-14 20:35:31 -04:00
using System.Xml ;
2017-08-31 12:08:38 -04:00
using Tools.DotNETCommon ;
2016-03-13 18:53:13 -04:00
using UnrealBuildTool ;
namespace AutomationTool.Tasks
{
/// <summary>
/// Parameters for the version task
/// </summary>
public class SetVersionTaskParameters
{
/// <summary>
/// The changelist to set in the version files
/// </summary>
[TaskParameter]
public int Change ;
2016-08-04 10:41:07 -04:00
/// <summary>
/// The engine compatible changelist to set in the version files
/// </summary>
[TaskParameter(Optional = true)]
public int CompatibleChange ;
2016-03-13 18:53:13 -04:00
/// <summary>
/// The branch string
/// </summary>
[TaskParameter]
public string Branch ;
2016-05-16 16:20:52 -04:00
/// <summary>
/// The build version string
/// </summary>
[TaskParameter(Optional = true)]
public string Build ;
2016-03-13 18:53:13 -04:00
/// <summary>
/// Whether to set the IS_LICENSEE_VERSION flag to true
/// </summary>
[TaskParameter(Optional = true)]
public bool Licensee ;
2016-12-13 11:58:16 -05:00
/// <summary>
/// Whether to set the ENGINE_IS_PROMOTED_BUILD flag to true
/// </summary>
[TaskParameter(Optional = true)]
public bool Promoted = true ;
2016-03-13 18:53:13 -04:00
/// <summary>
/// If set, don't actually write to the files - just return the version files that would be updated. Useful for local builds.
/// </summary>
[TaskParameter(Optional = true)]
public bool SkipWrite ;
2016-03-31 15:18:30 -04:00
/// <summary>
/// Tag to be applied to build products of this task
/// </summary>
2016-06-21 09:17:49 -04:00
[TaskParameter(Optional = true, ValidationType = TaskParameterValidationType.TagList)]
2016-03-31 15:18:30 -04:00
public string Tag ;
2016-03-13 18:53:13 -04:00
}
/// <summary>
2016-08-18 10:28:43 -04:00
/// Updates the local version files (Engine/Source/Runtime/Launch/Resources/Version.h, Engine/Build/Build.version, and Engine/Source/Programs/DotNETCommon/Metadata.cs) with the given version information.
2016-03-13 18:53:13 -04:00
/// </summary>
[TaskElement("SetVersion", typeof(SetVersionTaskParameters))]
public class SetVersionTask : CustomTask
{
/// <summary>
/// Parameters for the task
/// </summary>
SetVersionTaskParameters Parameters ;
/// <summary>
/// Construct a version task
/// </summary>
/// <param name="InParameters">Parameters for this task</param>
public SetVersionTask ( SetVersionTaskParameters 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>
2017-07-21 12:42:36 -04:00
public override void Execute ( JobContext Job , HashSet < FileReference > BuildProducts , Dictionary < string , HashSet < FileReference > > TagNameToFileSet )
2016-03-13 18:53:13 -04:00
{
2016-03-31 15:18:30 -04:00
// Update the version files
2018-08-14 18:32:34 -04:00
List < FileReference > VersionFiles = UE4Build . StaticUpdateVersionFiles ( Parameters . Change , Parameters . CompatibleChange , Parameters . Branch , Parameters . Build , Parameters . Licensee , Parameters . Promoted , ! Parameters . SkipWrite ) ;
2016-03-31 15:18:30 -04:00
// Apply the optional tag to them
2016-06-21 09:17:49 -04:00
foreach ( string TagName in FindTagNamesFromList ( Parameters . Tag ) )
2016-03-31 15:18:30 -04:00
{
2016-06-21 09:17:49 -04:00
FindOrAddTagSet ( TagNameToFileSet , TagName ) . UnionWith ( VersionFiles ) ;
2016-03-31 15:18:30 -04:00
}
// Add them to the list of build products
BuildProducts . UnionWith ( VersionFiles ) ;
2016-03-13 18:53:13 -04:00
}
2016-04-14 20:35:31 -04:00
/// <summary>
/// Output this task out to an XML writer.
/// </summary>
public override void Write ( XmlWriter Writer )
{
Write ( Writer , Parameters ) ;
}
2016-06-21 09:17:49 -04:00
/// <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 ( )
{
return FindTagNamesFromList ( Parameters . Tag ) ;
}
2016-03-13 18:53:13 -04:00
}
}