Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/BuildGraph/Tasks/PakFileTask.cs
Andrew Grant fad858c6db Copying //UE4/Orion-Staging to //UE4/Main (Source: //Orion/Dev-General @ 2912736)
#lockdown Nick.Penwarden

==========================
MAJOR FEATURES + CHANGES
==========================

Change 2912513 on 2016/03/16 by David.Ratti

	attempted cook fix
	#rb none
	#tests compile

Change 2912456 on 2016/03/16 by Zak.Middleton

	#ue4 - Move Replay client interpolation mode check to OnRegister(), out of TickComponent() so we don't check it constantly.

	#rb John.Pollard
	#tests Replays and MultiPIE vs AI

Change 2912386 on 2016/03/16 by Ben.Marsh

	BuildGraph: Add quotes around custom build node lists, so we can support node names with spaces.

Change 2912378 on 2016/03/16 by Ben.Marsh

	BuildGraph: Fix format of custom build arguments when running with buildgraph.

Change 2912318 on 2016/03/16 by Marcus.Wassmer

	Fix mallocleakdetection false positives, and hash collision data corruption.
	#rb none
	#test leak finding on goldenpath

Change 2912242 on 2016/03/16 by Lukasz.Furman

	CIS fix
	#rb none
	#tests none

Change 2912239 on 2016/03/16 by Ben.Marsh

	UBT: Include the project "Build" folder in the generated project files. It's pretty common to want to edit configuration data that's stored there.

	#rb none
	#tests generated project files using UGS after making change

Change 2912211 on 2016/03/16 by Ben.Marsh

	BuildFarm: Allow disabling the local DDC by setting the DDC override environment variable to "None". Testing performance of just using shared DDC for builders.

	#rb none
	#codereview Wes.Hunt
	#tests none

Change 2912196 on 2016/03/16 by Mieszko.Zielinski

	Added a missing #pragma once to GameplayDebuggerCompat.h #Orion

	#rb Lukasz.Furman
	#test none

Change 2912165 on 2016/03/16 by Lukasz.Furman

	new gameplay debugger and some replication fixes (disabled by default)
	uncommment debugger's setup line in FOrionGameModule::StartupModule to enable
	#orion
	#rb none
	#tests yes, a lot.
	#codereview Mieszko.Zielinski

Change 2912065 on 2016/03/16 by Jason.Bestimt

	[AUTOMERGE]

	#ORION_MAIN - Copy of DevUI (POST MERGE) @ CL 2912016

	#RB:none
	#Tests:none
	#CodeReview: matt.schembari

	--------
	Integrated using branch //Orion/Main_to_//Orion/Dev-General of change#2912060 by Jason.Bestimt on 2016/03/16 15:32:56.

Change 2912045 on 2016/03/16 by David.Ratti

	Add support for gameplay cues retrieiving the ability or gameplay effect level of the thing that instigated them. Also added level requirement settings in the addition particle system options in gameplay cues

	#rb DanY
	#tests PIE

Change 2912030 on 2016/03/16 by Alex.Fennell

	Merging //Portal/Dev-LibCurl_update/Engine/Source/Runtime/Online/... to //Orion/Dev-General/Engine/Source/Runtime/Online/...

	support for cookies across curl easy handles in libcurl

	#TESTS: cookie support confirmed by using the http test targetting google.com

	#RB: david.nikdel
	#codereview: david.nikdel, jason.bestimt

Change 2911870 on 2016/03/16 by Laurent.Delayen

	- Added FBranchingPointNotifyPayload used in AnimNotify and AnimNotifyState notifications.
	- FBranchingPointNotifyPayload includes MontageInstance InstanceID to uniquely identify which Montage it came from.
	- New notifications are backwards compatible with old.
	- Added bIsNativeBranchingPoint flag to notify classes to force them into branching points.

	#rb martin.wilson, frank.gigliotti
	#tests Kuro VS Rampage abilities in networked PIE

Change 2911763 on 2016/03/16 by Nick.Atamas

	Prevents a re-entrancy crash caused by potentially complex thumbnail generators. In general, we should not be doing heavy lifting in the asset browser until the user has released their mouse. This is especially true when a user is clicking on the content browser tab to bring it to front for the first time. This is probably a good change regardless of the re-entrancy issue.

	#rb none
	#test Editor does not crash.
	#codereview Matt.Kuhlenschmidt

Change 2911631 on 2016/03/16 by Dmitry.Rekman

	Fix AvgPing perfcounter being occasionally NaN (FORT-20523)

	- Prevent division by zero.

	#rb none

[CL 2917701 by Andrew Grant in Main branch]
2016-03-21 21:11:39 -04:00

184 lines
6.2 KiB
C#

using AutomationTool;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnrealBuildTool;
namespace BuildGraph.Tasks
{
/// <summary>
/// Parameters for a task that runs the cooker
/// </summary>
public class PakFileTaskParameters
{
/// <summary>
/// List of files, wildcards and tag sets to add to the pak file, separated by ';' characters.
/// </summary>
[TaskParameter]
public string Files;
/// <summary>
/// PAK file to output
/// </summary>
[TaskParameter]
public string Output;
/// <summary>
/// Directories to rebase the files relative to. If specified, the shortest path under a listed directory will be used for each file.
/// </summary>
[TaskParameter(Optional = true)]
public string RebaseDir;
/// <summary>
/// Script which gives the order of files
/// </summary>
[TaskParameter(Optional = true)]
public string Order;
/// <summary>
/// Encryption keys for this pak file
/// </summary>
[TaskParameter(Optional = true)]
public string Sign;
/// <summary>
/// Whether to compress files
/// </summary>
[TaskParameter(Optional = true)]
public bool Compress = true;
/// <summary>
/// Additional arguments to be passed to UnrealPak
/// </summary>
[TaskParameter(Optional = true)]
public string Arguments = "";
}
/// <summary>
/// Cook a selection of maps for a certain platform
/// </summary>
[TaskElement("PakFile", typeof(PakFileTaskParameters))]
public class PakFileTask : CustomTask
{
/// <summary>
/// Parameters for the task
/// </summary>
PakFileTaskParameters Parameters;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="InParameters">Parameters for this task</param>
public PakFileTask(PakFileTaskParameters 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>
/// <returns>True if the task succeeded</returns>
public override bool Execute(JobContext Job, HashSet<FileReference> BuildProducts, Dictionary<string, HashSet<FileReference>> TagNameToFileSet)
{
// Find the directories we're going to rebase relative to
HashSet<DirectoryReference> RebaseDirs = new HashSet<DirectoryReference>{ CommandUtils.RootDirectory };
if(Parameters.RebaseDir != null)
{
RebaseDirs.UnionWith(SplitDelimitedList(Parameters.RebaseDir).Select(x => ResolveDirectory(x)));
}
// Get the output parameter
FileReference OutputFile = ResolveFile(Parameters.Output);
// Get a unique filename for the response file
FileReference ResponseFile = FileReference.Combine(new DirectoryReference(CommandUtils.CmdEnv.LogFolder), String.Format("PakList_{0}.txt", OutputFile.GetFileNameWithoutExtension()));
for(int Idx = 2; ResponseFile.Exists(); Idx++)
{
ResponseFile = FileReference.Combine(ResponseFile.Directory, String.Format("PakList_{0}_{1}.txt", OutputFile.GetFileNameWithoutExtension(), Idx));
}
// Write out the response file
HashSet<FileReference> Files = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet);
using(StreamWriter Writer = new StreamWriter(ResponseFile.FullName, false, new System.Text.UTF8Encoding(true)))
{
foreach(FileReference File in Files)
{
string RelativePath = FindShortestRelativePath(File, RebaseDirs);
if(RelativePath == null)
{
CommandUtils.LogError("Couldn't find relative path for '{0}' - not under any rebase directories", File.FullName);
return false;
}
Writer.WriteLine("\"{0}\" \"{1}\"{2}", File.FullName, RelativePath, Parameters.Compress? " -compress" : "");
}
}
// Format the command line
StringBuilder CommandLine = new StringBuilder();
CommandLine.AppendFormat("{0} -create={1}", CommandUtils.MakePathSafeToUseWithCommandLine(OutputFile.FullName), CommandUtils.MakePathSafeToUseWithCommandLine(ResponseFile.FullName));
if(Parameters.Sign != null)
{
CommandLine.AppendFormat(" -sign={0}", CommandUtils.MakePathSafeToUseWithCommandLine(ResolveFile(Parameters.Sign).FullName));
}
if(Parameters.Order != null)
{
CommandLine.AppendFormat(" -order={0}", CommandUtils.MakePathSafeToUseWithCommandLine(ResolveFile(Parameters.Order).FullName));
}
if (GlobalCommandLine.Installed)
{
CommandLine.Append(" -installed");
}
if (GlobalCommandLine.UTF8Output)
{
CommandLine.AppendFormat(" -UTF8Output");
}
// Get the executable path
FileReference UnrealPakExe;
if(HostPlatform.Current.HostEditorPlatform == UnrealTargetPlatform.Win64)
{
UnrealPakExe = ResolveFile("Engine/Binaries/Win64/UnrealPak.exe");
}
else
{
UnrealPakExe = ResolveFile(String.Format("Engine/Binaries/{0}/UnrealPak", HostPlatform.Current.HostEditorPlatform.ToString()));
}
// Run it
CommandUtils.Log("Running '{0} {1}'", CommandUtils.MakePathSafeToUseWithCommandLine(UnrealPakExe.FullName), CommandLine.ToString());
CommandUtils.RunAndLog(CommandUtils.CmdEnv, UnrealPakExe.FullName, CommandLine.ToString(), Options: CommandUtils.ERunOptions.Default | CommandUtils.ERunOptions.UTF8Output);
BuildProducts.Add(OutputFile);
return true;
}
/// <summary>
/// Find the shortest relative path of the given file from a set of base directories.
/// </summary>
/// <param name="File">Full path to a file</param>
/// <param name="RebaseDirs">Possible base directories</param>
/// <returns>The shortest relative path, or null if the file is not under any of them</returns>
public static string FindShortestRelativePath(FileReference File, IEnumerable<DirectoryReference> RebaseDirs)
{
string RelativePath = null;
foreach(DirectoryReference RebaseDir in RebaseDirs)
{
if(File.IsUnderDirectory(RebaseDir))
{
string NewRelativePath = File.MakeRelativeTo(RebaseDir);
if(RelativePath == null || NewRelativePath.Length < RelativePath.Length)
{
RelativePath = NewRelativePath;
}
}
}
return RelativePath;
}
}
}