Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/Program.cs
Ben Marsh 6af6c038ea Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 2982165)
==========================
MAJOR FEATURES + CHANGES
==========================

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

	BuildGraph: Allow specifying optional dependencies for a node, indicating that the build products from an upstream node are desired, but should not block the node from running.

Change 2972295 on 2016/05/10 by Ben.Marsh

	EC: Remove spacing in notification emails to reduce size, and help prevent gmail from truncating messages. Also allow mailing notification emails when doing a dry run, and reading stream settings from another branch.

Change 2976096 on 2016/05/12 by Ben.Marsh

	EC: Store properties for the last succeeded builds, including the list of users that were notified about it.

Change 2976390 on 2016/05/12 by Ben.Marsh

	EC: Add a separate line to the notification email summary with a link to edit settings, and pass the missing ec-update parameter to set the last build status.

Change 2976441 on 2016/05/12 by Ben.Marsh

	UAT: Remove log file copy on builders after UAT failure. This is done outside the EC step that originally did it now.

Change 2976456 on 2016/05/12 by Ben.Marsh

	BuildGraph: Catch exceptions thrown by child processes failing when building or running UAT commands, and return failure normally without dumping callstacks.

Change 2978440 on 2016/05/16 by Ben.Marsh

	EC: Age out entries from the "latest builds" list after a week. There's no obvious way to tell if a node has been removed, but a periodic cleanup should keep the build notifications list in check.

Change 2979446 on 2016/05/16 by Ben.Marsh

	Rename ambiguous headers which exist with the same name in different paths.

Change 2979839 on 2016/05/16 by Ben.Marsh

	UE4: Renaming HTML5 SocketSubsystem files to eliminate ambiguities.

Change 2979852 on 2016/05/16 by Ben.Marsh

	UE4: Use explicit relative paths for public headers in PortalServiceInterfaces modules which do not have unique names

Change 2980113 on 2016/05/17 by Ben.Marsh

	UE4: Fix include paths for HTML5 SocketSubsystem files.

Change 2980117 on 2016/05/17 by Ben.Marsh

	UE4: Remove reference to private PCH from Oculus common code.

Change 2980186 on 2016/05/17 by Ben.Marsh

	UAT: Add a -StopOnErrors parameter to UE4Build, which is propagated to XGE.

Change 2980879 on 2016/05/17 by Ben.Marsh

	UE4: Fixup Lightmass to use LightmassPCH.h rather than stdafx.h

Change 2981117 on 2016/05/17 by Ben.Marsh

	Portal: Use a unique name for the Portal PCH, rather than just calling it PrivatePCH.h

Change 2981839 on 2016/05/18 by Ben.Marsh

	Replace ambiguous D3D11/D3D12 includes with direct includes for the current platform.

#lockdown Nick.Penwarden

[CL 2982178 by Ben Marsh in Main branch]
2016-05-18 13:26:45 -04:00

143 lines
5.2 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
// This software is provided "as-is," without any express or implied warranty.
// In no event shall the author, nor Epic Games, Inc. be held liable for any damages arising from the use of this software.
// This software will not be supported.
// Use at your own risk.
using System;
using System.Threading;
using System.Diagnostics;
using UnrealBuildTool;
using System.Reflection;
using Tools.DotNETCommon;
using System.IO;
namespace AutomationTool
{
public class Program
{
/// <summary>
/// Keep a persistent reference to the delegate for handling Ctrl-C events. Since it's passed to non-managed code, we have to prevent it from being garbage collected.
/// </summary>
static ProcessManager.CtrlHandlerDelegate CtrlHandlerDelegateInstance = CtrlHandler;
[STAThread]
public static int Main()
{
var CommandLine = SharedUtils.ParseCommandLine();
LogUtils.InitLogging(CommandLine);
ExitCode ReturnCode = ExitCode.Success;
try
{
// ensure we can resolve any external assemblies as necessary.
AssemblyUtils.InstallAssemblyResolver(Path.GetDirectoryName(Assembly.GetEntryAssembly().GetOriginalLocation()));
HostPlatform.Initialize();
Log.TraceVerbose("{2}: Running on {0} as a {1}-bit process.", HostPlatform.Current.GetType().Name, Environment.Is64BitProcess ? 64 : 32, DateTime.UtcNow.ToString("o"));
XmlConfigLoader.Init();
// Log if we're running from the launcher
var ExecutingAssemblyLocation = Assembly.GetExecutingAssembly().Location;
if (string.Compare(ExecutingAssemblyLocation, Assembly.GetEntryAssembly().GetOriginalLocation(), StringComparison.OrdinalIgnoreCase) != 0)
{
Log.TraceVerbose("Executed from AutomationToolLauncher ({0})", ExecutingAssemblyLocation);
}
Log.TraceVerbose("CWD={0}", Environment.CurrentDirectory);
// Hook up exit callbacks
var Domain = AppDomain.CurrentDomain;
Domain.ProcessExit += Domain_ProcessExit;
Domain.DomainUnload += Domain_ProcessExit;
HostPlatform.Current.SetConsoleCtrlHandler(CtrlHandlerDelegateInstance);
var Version = AssemblyUtils.ExecutableVersion;
Log.TraceVerbose("{0} ver. {1}", Version.ProductName, Version.ProductVersion);
// Don't allow simultaneous execution of AT (in the same branch)
ReturnCode = InternalUtils.RunSingleInstance(MainProc, CommandLine);
}
catch (AutomationException Ex)
{
Log.TraceError("AutomationTool terminated with exception: {0}", Ex);
ReturnCode = Ex.ErrorCode;
}
catch (Exception Ex)
{
// Catch all exceptions and propagate the ErrorCode if we are given one.
Log.TraceError("AutomationTool terminated with exception: {0}", Ex);
ReturnCode = ExitCode.Error_Unknown;
}
finally
{
// In all cases, do necessary shut down stuff, but don't let any additional exceptions leak out while trying to shut down.
// Make sure there's no directories on the stack.
NoThrow(() => CommandUtils.ClearDirStack(), "Clear Dir Stack");
// Try to kill process before app domain exits to leave the other KillAll call to extreme edge cases
NoThrow(() => { if (ShouldKillProcesses && !Utils.IsRunningOnMono) ProcessManager.KillAll(); }, "Kill All Processes");
Log.TraceInformation("AutomationTool exiting with ExitCode={0} ({1})", (int)ReturnCode, ReturnCode);
// Can't use NoThrow here because the code logs exceptions. We're shutting down logging!
LogUtils.ShutdownLogging();
}
// STOP: No code beyond the return statement should go beyond this point!
// Nothing should happen after the finally block above is finished.
return (int)ReturnCode;
}
/// <summary>
/// Wraps an action in an exception block.
/// Ensures individual actions can be performed and exceptions won't prevent further actions from being executed.
/// Useful for shutdown code where shutdown may be in several stages and it's important that all stages get a chance to run.
/// </summary>
/// <param name="Action"></param>
private static void NoThrow(System.Action Action, string ActionDesc)
{
try
{
Action();
}
catch (Exception Ex)
{
Log.TraceError("Exception performing nothrow action \"{0}\": {1}", ActionDesc, LogUtils.FormatException(Ex));
}
}
static bool CtrlHandler(CtrlTypes EventType)
{
Domain_ProcessExit(null, null);
if (EventType == CtrlTypes.CTRL_C_EVENT)
{
// Force exit
Environment.Exit(3);
}
return true;
}
static void Domain_ProcessExit(object sender, EventArgs e)
{
// Kill all spawned processes (Console instead of Log because logging is closed at this time anyway)
if (ShouldKillProcesses && !Utils.IsRunningOnMono)
{
ProcessManager.KillAll();
}
Trace.Close();
}
static ExitCode MainProc(object Param)
{
ExitCode Result = Automation.Process((string[])Param);
ShouldKillProcesses = Automation.ShouldKillProcesses;
return Result;
}
static bool ShouldKillProcesses = true;
}
}