Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/Scripts/BuildCookRun.Automation.cs
Andrew Grant 0b4257e23a Copying //UE4/Orion-Staging to //UE4/Main (Source //Orion/Dev-General @ 2927258)
#lockdown Nick.Penwarden

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

Change 2927181 on 2016/03/29 by Dmitry.Rekman

	(Optionally) exclude idle time from server FPS charts.

	- Time spent waiting for the next frame in order to hit capped FPS can be optionally excluded by using t.FPSChart.ExcludeIdleTime (set to 1 for servers).
	- Server FPS charts analytics events and log output will include the information if idle time was excluded.

	- Also: added a log line each time we detect a server hitch for easier pin-pointing them in the log.

	#rb Paul.Moore
	#codereview Paul.Moore, Michael.Noland
	#tests Ran Linux server and Windows client on compatible content.

Change 2927084 on 2016/03/29 by Ben.Marsh

	BuildGraph: Don't allow triggers to run until all their order dependencies are complete. Just because a downstream node doesn't have a dependency on an upstream node via temp storage doesn't mean it can run immediately.

	#rb none
	#tests none

Change 2927060 on 2016/03/29 by Michael.Noland

	Renamed GPU analytics event from GPU to DesktopGPU to reflect that it is the default desktop adapter and not the one we initialized (which is GPUAdapter)
	Updated text/log based FPS chart events to print out GPUAdapter instead (with DesktopGPU in parens if they differ, e.g., in an optimus setup)
	#rb marcus.wassmer
	#tests Ran and did some fps charts

Change 2927048 on 2016/03/29 by Michael.Noland

	HLOD: Removed an unused cvar r.HLODEnabled (everything is done thru r.HLOD)
	#tests Compiled and ran Paragon
	#rb marcus.wassmer

Change 2926920 on 2016/03/29 by Ben.Marsh

	BuildGraph: Update schema with Rename task.

Change 2926911 on 2016/03/29 by Ben.Marsh

	BuildGraph: Add a task which can rename files matching a given wildcard. Syntax is: <Rename Files="*.txt" To="*.md"> or <Rename Files="Engine/Build/..." From="*.txt" To="*.md"/>

	#rb none
	#tests none

Change 2926908 on 2016/03/29 by Andrew.Grant

	Fix for CDO properties of renamed blueprints not being applied
	#rb none
	#tests loaded Origin map (renamed from Playgo3) and verified properties are applied.

Change 2926799 on 2016/03/29 by Jason.Bestimt

	#ORION_DG - Merge MAIN (23) @ CL# 2926780

	#RB:none
	#Tests:none

Change 2926663 on 2016/03/29 by david.nikdel

	#ROBOMERGE-OBO: jason.bestimt
	#ROBOMERGE-SOURCE: CL 2926660 in //Orion/Release-0.23/... via CL 2926662
	#ROBOMERGE-BOT: ORION (Main -> Dev-General)

	#ORION_23 - Potential fix for Cook failures

	"Fix shelved in 2926635, tested in Dev-Blueprints. Could not run any GEditor related logic safely in ShutdownModule because of the same destruction issue orders that caused the bug in the first place. I will chat with Editor team about nulling out GEditor the same way we null out GUnrealEd."

	#RB:none
	#Tests: none

	[CodeReviewed]: andrew.grant, dan.oconnor

Change 2926510 on 2016/03/29 by Andrew.Grant

	Potential fix for OR-18207 - editor becomes unresponsive (audio deadlock)
	#rb none
	#tests compiled

Change 2926495 on 2016/03/29 by Rob.Cannaday

	Change storing HTTP requests as raw pointers to weak pointers with validity being checked via Pinning it
	#jira FORT-18947
	#jira OR-17695
	#tests golden path
	#rb eric.newman

Change 2926427 on 2016/03/29 by Josh.Markiewicz

	#UE4 - fixed typo
	#rb none
	#tests none

Change 2926250 on 2016/03/29 by Martin.Mittring

	fixed OR-18489 HERO: IGGY: RMB on E ability causes blinding hair effect
	#rb:Chris.Bunner
	#codereview:Brian.Karis

Change 2926224 on 2016/03/29 by Daniel.Lamb

	Fix for potenital threading issue with Console manager removing vars which could cause double free.
	#rb Robert.Manuszewski
	#test Orion cook

Change 2926174 on 2016/03/29 by Gareth.Martin

	Cloned fix for bUseMaterialPositionOffsetInStaticLighting crashing across from //UE4/Dev-Landscape/ to unblock people
	#rb
	#tests editor

Change 2925968 on 2016/03/29 by David.Nikdel

	#MCP #OSS
	- Read RedirectUrl from ini

	#RB: Eric.Newman
	#TESTS: compiled in another branch (merge over)
	#ROBOMERGE: Main

[CL 2929424 by Andrew Grant in Main branch]
2016-03-31 15:18:30 -04:00

348 lines
10 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Reflection;
using AutomationTool;
using UnrealBuildTool;
[Help(@"Builds/Cooks/Runs a project.
For non-uprojects project targets are discovered by compiling target rule files found in the project folder.
If -map is not specified, the command looks for DefaultMap entry in the project's DefaultEngine.ini and if not found, in BaseEngine.ini.
If no DefaultMap can be found, the command falls back to /Engine/Maps/Entry.")]
[Help("project=Path", @"Project path (required), i.e: -project=QAGame, -project=Samples\BlackJack\BlackJack.uproject, -project=D:\Projects\MyProject.uproject")]
[Help("destsample", "Destination Sample name")]
[Help("foreigndest", "Foreign Destination")]
[Help(typeof(ProjectParams))]
[Help(typeof(UE4Build))]
[Help(typeof(CodeSign))]
public class BuildCookRun : BuildCommand
{
#region BaseCommand interface
public override void ExecuteBuild()
{
// allow BCR functions to call UBT functions (especially .ini parsing)
UnrealBuildTool.UnrealBuildTool.SetupUBTFromUAT();
// these need to be done first
var bForeign = ParseParam("foreign");
var bForeignCode = ParseParam("foreigncode");
if (bForeign)
{
MakeForeignSample();
}
else if (bForeignCode)
{
MakeForeignCodeSample();
}
var Params = SetupParams();
DoBuildCookRun(Params);
}
#endregion
#region Setup
protected ProjectParams SetupParams()
{
Log("Setting up ProjectParams for {0}", ProjectPath);
var Params = new ProjectParams
(
Command: this,
// Shared
RawProjectPath: ProjectPath
);
var DirectoriesToCook = ParseParamValue("cookdir");
if (!String.IsNullOrEmpty(DirectoriesToCook))
{
Params.DirectoriesToCook = new ParamList<string>(DirectoriesToCook.Split('+'));
}
var InternationalizationPreset = ParseParamValue("i18npreset");
if (!String.IsNullOrEmpty(InternationalizationPreset))
{
Params.InternationalizationPreset = InternationalizationPreset;
}
var CulturesToCook = ParseParamValue("cookcultures");
if (!String.IsNullOrEmpty(CulturesToCook))
{
Params.CulturesToCook = new ParamList<string>(CulturesToCook.Split('+'));
}
if (Params.DedicatedServer)
{
foreach (var ServerPlatformInstance in Params.ServerTargetPlatformInstances)
{
ServerPlatformInstance.PlatformSetupParams(ref Params);
}
}
else
{
foreach (var ClientPlatformInstance in Params.ClientTargetPlatformInstances)
{
ClientPlatformInstance.PlatformSetupParams(ref Params);
}
}
Params.ValidateAndLog();
return Params;
}
/// <summary>
/// In case the command line specified multiple map names with a '+', selects the first map from the list.
/// </summary>
/// <param name="Maps">Map(s) specified in the commandline.</param>
/// <returns>First map or an empty string.</returns>
private static string GetFirstMap(string Maps)
{
string Map = String.Empty;
if (!String.IsNullOrEmpty(Maps))
{
var AllMaps = Maps.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
if (!IsNullOrEmpty(AllMaps))
{
Map = AllMaps[0];
}
}
return Map;
}
private string GetTargetName(Type TargetRulesType)
{
const string TargetPostfix = "Target";
var Name = TargetRulesType.Name;
if (Name.EndsWith(TargetPostfix, StringComparison.InvariantCultureIgnoreCase))
{
Name = Name.Substring(0, Name.Length - TargetPostfix.Length);
}
return Name;
}
private string GetDefaultMap(ProjectParams Params)
{
const string EngineEntryMap = "/Engine/Maps/Entry";
Log("Trying to find DefaultMap in ini files");
string DefaultMap = null;
var ProjectFolder = GetDirectoryName(Params.RawProjectPath.FullName);
var DefaultGameEngineConfig = CombinePaths(ProjectFolder, "Config", "DefaultEngine.ini");
if (FileExists(DefaultGameEngineConfig))
{
Log("Looking for DefaultMap in {0}", DefaultGameEngineConfig);
DefaultMap = GetDefaultMapFromIni(DefaultGameEngineConfig, Params.DedicatedServer);
if (DefaultMap == null && Params.DedicatedServer)
{
DefaultMap = GetDefaultMapFromIni(DefaultGameEngineConfig, false);
}
}
else
{
var BaseEngineConfig = CombinePaths(CmdEnv.LocalRoot, "Config", "BaseEngine.ini");
if (FileExists(BaseEngineConfig))
{
Log("Looking for DefaultMap in {0}", BaseEngineConfig);
DefaultMap = GetDefaultMapFromIni(BaseEngineConfig, Params.DedicatedServer);
if (DefaultMap == null && Params.DedicatedServer)
{
DefaultMap = GetDefaultMapFromIni(BaseEngineConfig, false);
}
}
}
// We check for null here becase null == not found
if (DefaultMap == null)
{
Log("No DefaultMap found, assuming: {0}", EngineEntryMap);
DefaultMap = EngineEntryMap;
}
else
{
Log("Found DefaultMap={0}", DefaultMap);
}
return DefaultMap;
}
private string GetDefaultMapFromIni(string IniFilename, bool DedicatedServer)
{
var IniLines = ReadAllLines(IniFilename);
string DefaultMap = null;
string ConfigKeyStr = "GameDefaultMap";
if (DedicatedServer)
{
ConfigKeyStr = "ServerDefaultMap";
}
foreach (var Line in IniLines)
{
if (Line.StartsWith(ConfigKeyStr, StringComparison.InvariantCultureIgnoreCase))
{
var DefaultMapPair = Line.Split('=');
DefaultMap = DefaultMapPair[1].Trim();
}
if (DefaultMap != null)
{
break;
}
}
return DefaultMap;
}
#endregion
#region BuildCookRun
protected void DoBuildCookRun(ProjectParams Params)
{
const ProjectBuildTargets ClientTargets = ProjectBuildTargets.ClientCooked | ProjectBuildTargets.ServerCooked;
bool bGenerateNativeScripts = Params.RunAssetNativization;
int WorkingCL = -1;
if (P4Enabled && AllowSubmit)
{
WorkingCL = P4.CreateChange(P4Env.Client, String.Format("{0} build from changelist {1}", Params.ShortProjectName, P4Env.Changelist));
}
Project.Build(this, Params, WorkingCL, bGenerateNativeScripts ? (ProjectBuildTargets.All & ~ClientTargets) : ProjectBuildTargets.All);
Project.Cook(Params);
if (bGenerateNativeScripts)
{
Project.Build(this, Params, WorkingCL, ClientTargets);
}
Project.CopyBuildToStagingDirectory(Params);
Project.Package(Params, WorkingCL);
Project.Archive(Params);
Project.Deploy(Params);
PrintRunTime();
Project.Run(Params);
// Check everything in!
if (WorkingCL != -1)
{
int SubmittedCL;
P4.Submit(WorkingCL, out SubmittedCL, true, true);
}
}
private void MakeForeignSample()
{
string Sample = "BlankProject";
var DestSample = ParseParamValue("DestSample", "CopiedBlankProject");
var Src = CombinePaths(CmdEnv.LocalRoot, "Samples", "SampleGames", Sample);
if (!DirectoryExists(Src))
{
throw new AutomationException("Can't find source directory to make foreign sample {0}.", Src);
}
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
Log("Make a foreign sample {0} -> {1}", Src, Dest);
CloneDirectory(Src, Dest);
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Intermediate"));
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Saved"));
RenameFile(CombinePaths(Dest, Sample + ".uproject"), CombinePaths(Dest, DestSample + ".uproject"));
var IniFile = CombinePaths(Dest, "Config", "DefaultEngine.ini");
var Ini = new VersionFileUpdater(IniFile);
Ini.ReplaceLine("GameName=", DestSample);
Ini.Commit();
}
private void MakeForeignCodeSample()
{
string Sample = "PlatformerGame";
string DestSample = "PlatformerGame";
var Src = CombinePaths(CmdEnv.LocalRoot, Sample);
if (!DirectoryExists(Src))
{
throw new AutomationException("Can't find source directory to make foreign sample {0}.", Src);
}
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
Log("Make a foreign sample {0} -> {1}", Src, Dest);
CloneDirectory(Src, Dest);
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Intermediate"));
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Saved"));
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Plugins", "FootIK", "Intermediate"));
//RenameFile(CombinePaths(Dest, Sample + ".uproject"), CombinePaths(Dest, DestSample + ".uproject"));
var IniFile = CombinePaths(Dest, "Config", "DefaultEngine.ini");
var Ini = new VersionFileUpdater(IniFile);
Ini.ReplaceLine("GameName=", DestSample);
Ini.Commit();
}
private FileReference ProjectFullPath;
public virtual FileReference ProjectPath
{
get
{
if (ProjectFullPath == null)
{
var bForeign = ParseParam("foreign");
var bForeignCode = ParseParam("foreigncode");
if (bForeign)
{
var DestSample = ParseParamValue("DestSample", "CopiedHoverShip");
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
ProjectFullPath = new FileReference(CombinePaths(Dest, DestSample + ".uproject"));
}
else if (bForeignCode)
{
var DestSample = ParseParamValue("DestSample", "PlatformerGame");
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
ProjectFullPath = new FileReference(CombinePaths(Dest, DestSample + ".uproject"));
}
else
{
var OriginalProjectName = ParseParamValue("project", "");
if (string.IsNullOrEmpty(OriginalProjectName))
{
throw new AutomationException("No project file specified. Use -project=<project>.");
}
var ProjectName = OriginalProjectName;
ProjectName = ProjectName.Trim(new char[] { '\"' });
if (ProjectName.IndexOfAny(new char[] { '\\', '/' }) < 0)
{
ProjectName = CombinePaths(CmdEnv.LocalRoot, ProjectName, ProjectName + ".uproject");
}
else if (!FileExists_NoExceptions(ProjectName))
{
ProjectName = CombinePaths(CmdEnv.LocalRoot, ProjectName);
}
if(FileExists_NoExceptions(ProjectName))
{
ProjectFullPath = new FileReference(ProjectName);
}
else
{
var Branch = new BranchInfo(new List<UnrealTargetPlatform> { UnrealBuildTool.BuildHostPlatform.Current.Platform });
var GameProj = Branch.FindGame(OriginalProjectName);
if (GameProj != null)
{
ProjectFullPath = GameProj.FilePath;
}
if (!FileExists_NoExceptions(ProjectFullPath.FullName))
{
throw new AutomationException("Could not find a project file {0}.", ProjectName);
}
}
}
}
return ProjectFullPath;
}
}
#endregion
}