Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/System/CustomBuildSteps.cs
Ben Marsh 40f391e11e Copying //UE4/Dev-Build to //UE4/Main
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2857832 on 2016/02/05 by Ben.Marsh

	GitHub #1959 - Prevent UELinkerFixups file from using shared PCHs; it doesn't necessarily have the right compile environment to be able to use them.

Change 2858189 on 2016/02/06 by Ben.Marsh

	Allow runtime dependencies to be optional, so we can allow games to be staged without requiring PhysX/Apex PDBs.

Change 2858968 on 2016/02/08 by Ben.Marsh

	Allow plugins to be enabled/disabled depending on different target types. Contributed by Ben Everett/Hi-Rez Studios.

Change 2859325 on 2016/02/08 by Ben.Marsh

	Stop adding a debug output device if it goes to the same place as the regular log output device. Prevent output messages printing to the log twice on Mac.

	#codereview Michael.Trepka

Change 2859995 on 2016/02/09 by Matthew.Griffin

	Changed UnrealFileServer to be non-monolithic so that it doesn't include code that is not public

Change 2860393 on 2016/02/09 by Ben.Marsh

	Add support for pre and post build steps for projects and plugin files. Steps are specified as a list of shell commands per-target platform, and are written to a shell script by UBT. Whenever the target is built, the pre-build steps are executed before UHT, and post-build steps are executed at the end.

	The following target properties are expanded with UBT properties in the commands: $(EngineDir), $(ProjectDir), $(TargetName), $(TargetPlatform), $(TargetConfiguration), $(TargetType), $(ProjectFile), $(PluginDir).

	Example JSON fragment:

		"PreBuildSteps": {
			"Win64": [
				"echo EngineDir=$(EngineDir)",
				"echo ProjectDir=$(ProjectDir)",
				"echo TargetName=$(TargetName)",
				"echo TargetPlatform=$(TargetPlatform)",
				"echo TargetConfiguration=$(TargetConfiguration)",
				"echo TargetType=$(TargetType)",
				"echo ProjectFile=$(ProjectFile)",
				"echo PluginDir=$(PluginDir)"
			]
		},

Change 2860504 on 2016/02/09 by Ben.Marsh

	Remove nodes from the grid view that we don't have any data for.

Change 2860592 on 2016/02/09 by Ben.Marsh

	Add script to copy all UAT/UBT build products to another directory. To be used to avoid compiling multiple times on build system.

Change 2861087 on 2016/02/09 by Ben.Marsh

	Allow UAT binaries compiled on the initial agent to be copied to all other agents in a build. Saves a lot of startup time on Mac, in particular.

Change 2861788 on 2016/02/10 by Ben.Marsh

	Fix warnings and mangled notification email if triggers finish before all their jobsteps have been created.

#lockdown Nick.Penwarden

[CL 2863732 by Ben Marsh in Main branch]
2016-02-11 15:36:17 -05:00

106 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnrealBuildTool
{
public class CustomBuildSteps
{
SortedDictionary<UnrealTargetPlatform, string[]> HostPlatformToCommands = new SortedDictionary<UnrealTargetPlatform,string[]>();
/// <summary>
/// Construct a custom build steps object from a Json object.
/// </summary>
public CustomBuildSteps(JsonObject RawObject)
{
foreach(string HostPlatformName in RawObject.KeyNames)
{
UnrealTargetPlatform HostPlatform;
if(Enum.TryParse(HostPlatformName, true, out HostPlatform))
{
HostPlatformToCommands.Add(HostPlatform, RawObject.GetStringArrayField(HostPlatformName));
}
}
}
/// <summary>
/// Reads a list of build steps from a Json project or plugin descriptor
/// </summary>
/// <param name="RawObject">The json descriptor object</param>
/// <param name="FieldName">Name of the field to read</param>
/// <param name="OutBuildSteps">Output variable to store the sorted dictionary that was read</param>
/// <returns>True if the field was read (and OutBuildSteps is set), false otherwise.</returns>
public static bool TryRead(JsonObject RawObject, string FieldName, out CustomBuildSteps OutBuildSteps)
{
JsonObject BuildStepsObject;
if(RawObject.TryGetObjectField(FieldName, out BuildStepsObject))
{
OutBuildSteps = new CustomBuildSteps(BuildStepsObject);
return true;
}
else
{
OutBuildSteps = null;
return false;
}
}
/// <summary>
/// Reads a list of build steps from a Json project or plugin descriptor
/// </summary>
/// <param name="RawObject">The json descriptor object</param>
/// <param name="FieldName">Name of the field to read</param>
/// <param name="OutBuildSteps">Output variable to store the sorted dictionary that was read</param>
/// <returns>True if the field was read (and OutBuildSteps is set), false otherwise.</returns>
public void Write(JsonWriter Writer, string FieldName)
{
Writer.WriteObjectStart(FieldName);
foreach(KeyValuePair<UnrealTargetPlatform, string[]> Pair in HostPlatformToCommands)
{
Writer.WriteArrayStart(Pair.Key.ToString());
foreach(string Line in Pair.Value)
{
Writer.WriteValue(Line);
}
Writer.WriteArrayEnd();
}
Writer.WriteObjectEnd();
}
/// <summary>
/// Determines whether there are custom build steps for the given host platform
/// </summary>
/// <param name="HostPlatform">The host platform to check for</param>
/// <returns>True if the host platform exists</returns>
public bool HasHostPlatform(UnrealTargetPlatform HostPlatform)
{
string[] Commands;
return HostPlatformToCommands.TryGetValue(HostPlatform, out Commands) && Commands.Length > 0;
}
/// <summary>
/// Tries to get the commands for a given host platform
/// </summary>
/// <param name="HostPlatform">The host platform to look for</param>
/// <param name="Variables">Lookup of additional environment variables to expand</param>
/// <param name="OutCommands">Array of commands</param>
/// <returns>True if a list of commands was generated</returns>
public bool TryGetCommands(UnrealTargetPlatform HostPlatform, Dictionary<string, string> Variables, out string[] OutCommands)
{
string[] Commands;
if(HostPlatformToCommands.TryGetValue(HostPlatform, out Commands) && Commands.Length > 0)
{
OutCommands = Commands.Select(x => Utils.ExpandVariables(x, Variables)).ToArray();
return true;
}
else
{
OutCommands = null;
return false;
}
}
}
}