Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/System/PlatformExports.cs
andrew grant f677f27652 Check if the XGE service is running as part of the availability check.
UE4Build / BuildCookRun doesn't check BuildConfiguration.xml* before initiating builds so people who have the IB service installed but disabled will see builds sent to XGE that fail with "Failed to connect to Build Service (on local machine)".

#tests ran BuildCookRun -build with and without the XGE agent service disabled.Verified that builds fell back to local execution with the service disabled and still attempted XGE builds with it enabled.

[REVIEW] [at]ben.marsh
#rb swarm


#ROBOMERGE-SOURCE: CL 12357374 via CL 12357377 via CL 12357379 via CL 12357386
#ROBOMERGE-BOT: (v671-12333473)

[CL 12369934 by andrew grant in Main branch]
2020-03-23 10:37:35 -04:00

164 lines
5.7 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tools.DotNETCommon;
namespace UnrealBuildTool
{
/// <summary>
/// General platform support functions, exported for UAT
/// </summary>
public class PlatformExports
{
/// <summary>
/// Checks whether the given platform is available
/// </summary>
/// <param name="Platform">Platform to check</param>
/// <returns>True if the platform is available, false otherwise</returns>
public static bool IsPlatformAvailable(UnrealTargetPlatform Platform)
{
return UEBuildPlatform.IsPlatformAvailable(Platform);
}
/// <summary>
/// Gets a list of the registered platforms
/// </summary>
/// <returns>List of platforms</returns>
public static IEnumerable<UnrealTargetPlatform> GetRegisteredPlatforms()
{
return UEBuildPlatform.GetRegisteredPlatforms();
}
/// <summary>
/// Gets the default architecture for a given platform
/// </summary>
/// <param name="Platform">The platform to get the default architecture for</param>
/// <param name="ProjectFile">Project file to read settings from</param>
/// <returns>The default architecture</returns>
public static string GetDefaultArchitecture(UnrealTargetPlatform Platform, FileReference ProjectFile)
{
return UEBuildPlatform.GetBuildPlatform(Platform).GetDefaultArchitecture(ProjectFile);
}
/// <summary>
/// Checks whether the given project has a default build configuration
/// </summary>
/// <param name="ProjectFile">The project file</param>
/// <param name="Platform">Platform to check settings for</param>
/// <returns>True if the project uses the default build configuration</returns>
public static bool HasDefaultBuildConfig(FileReference ProjectFile, UnrealTargetPlatform Platform)
{
UEBuildPlatform BuildPlat = UEBuildPlatform.GetBuildPlatform(Platform, true);
return (BuildPlat == null)? true : BuildPlat.HasDefaultBuildConfig(Platform, ProjectFile.Directory);
}
/// <summary>
/// Checks whether the given project requires a build because of platform needs
/// </summary>
/// <param name="ProjectFile">The project file</param>
/// <param name="Platform">Platform to check settings for</param>
/// <returns>True if the project requires a build for the platform</returns>
public static bool RequiresBuild(FileReference ProjectFile, UnrealTargetPlatform Platform)
{
UEBuildPlatform BuildPlat = UEBuildPlatform.GetBuildPlatform(Platform, true);
return (BuildPlat == null) ? false : BuildPlat.RequiresBuild(Platform, ProjectFile.Directory);
}
/// <summary>
/// Returns an array of all platform folder names
/// </summary>
/// <returns>All platform folder names</returns>
public static string[] GetPlatformFolderNames()
{
return UEBuildPlatform.GetPlatformFolderNames();
}
/// <summary>
/// Returns an array of all platform folder names
/// </summary>
/// <param name="Platform">The platform to get the included folder names for</param>
/// <returns>All platform folder names</returns>
public static string[] GetIncludedFolderNames(UnrealTargetPlatform Platform)
{
UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform, false);
return BuildPlatform.GetIncludedFolderNames().ToArray();
}
/// <summary>
/// Returns all the excluded folder names for a given platform
/// </summary>
/// <param name="Platform">The platform to get the excluded folder names for</param>
/// <returns>Array of folder names</returns>
public static string[] GetExcludedFolderNames(UnrealTargetPlatform Platform)
{
UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform, false);
return BuildPlatform.GetExcludedFolderNames().ToArray();
}
/// <summary>
/// Check whether the given platform supports XGE
/// </summary>
/// <param name="Platform">Platform to check</param>
/// <returns>True if the platform supports XGE</returns>
public static bool CanUseXGE(UnrealTargetPlatform Platform)
{
return UEBuildPlatform.IsPlatformAvailable(Platform) && UEBuildPlatform.GetBuildPlatform(Platform).CanUseXGE() && XGE.IsAvailable();
}
/// <summary>
/// Check whether the given platform supports the parallel executor in UAT
/// </summary>
/// <param name="Platform">Platform to check</param>
/// <returns>True if the platform supports the parallel executor in UAT</returns>
public static bool CanUseParallelExecutor(UnrealTargetPlatform Platform)
{
return UEBuildPlatform.IsPlatformAvailable(Platform) && UEBuildPlatform.GetBuildPlatform(Platform).CanUseParallelExecutor();
}
/// <summary>
/// Gets the path for the XGE console executable
/// </summary>
/// <param name="OutXgConsoleExe">On success, receives the path to the XGE console executable</param>
/// <returns>True if the path was found, false otherwise</returns>
public static bool TryGetXgConsoleExecutable(out string OutXgConsoleExe)
{
return XGE.TryGetXgConsoleExecutable(out OutXgConsoleExe);
}
/// <summary>
///
/// </summary>
public static void PreventAutoSDKSwitching()
{
UEBuildPlatformSDK.bAllowAutoSDKSwitching = false;
}
/// <summary>
///
/// </summary>
/// <param name="Path"></param>
public static void SetRemoteIniPath(string Path)
{
UnrealBuildTool.SetRemoteIniPath(Path);
}
/// <summary>
/// Initialize UBT in the context of another host process (presumably UAT)
/// </summary>
/// <returns>True if initialization was successful</returns>
public static bool Initialize()
{
// Read the XML configuration files
XmlConfig.ReadConfigFiles(null);
// Register all the platform classes
UEBuildPlatform.RegisterPlatforms(false, false);
return true;
}
}
}