// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using EpicGames.Core;
using Microsoft.Extensions.Logging;
namespace UnrealBuildTool
{
///
/// General platform support functions, exported for UAT
///
public class PlatformExports
{
///
/// Checks whether the given platform is available
///
/// Platform to check
/// True if the platform is available, false otherwise
public static bool IsPlatformAvailable(UnrealTargetPlatform Platform)
{
return UEBuildPlatform.IsPlatformAvailable(Platform);
}
///
/// Gets a list of the registered platforms
///
/// List of platforms
public static IEnumerable GetRegisteredPlatforms()
{
return UEBuildPlatform.GetRegisteredPlatforms();
}
///
/// Checks whether the given project has a default build configuration
///
/// The project file
/// Platform to check settings for
/// True if the project uses the default build configuration
public static bool HasDefaultBuildConfig(FileReference ProjectFile, UnrealTargetPlatform Platform)
{
UEBuildPlatform.TryGetBuildPlatform(Platform, out UEBuildPlatform? BuildPlat);
return (BuildPlat == null) || BuildPlat.HasDefaultBuildConfig(Platform, ProjectFile.Directory);
}
///
/// Checks whether the given project requires a build because of platform needs
///
/// The project file
/// Platform to check settings for
/// True if the project requires a build for the platform
public static bool RequiresBuild(FileReference ProjectFile, UnrealTargetPlatform Platform)
{
UEBuildPlatform.TryGetBuildPlatform(Platform, out UEBuildPlatform? BuildPlat);
return BuildPlat?.RequiresBuild(Platform, ProjectFile.Directory) == true;
}
///
/// Returns an array of all platform folder names
///
/// All platform folder names
public static string[] GetPlatformFolderNames()
{
return UEBuildPlatform.GetPlatformFolderNames();
}
///
/// Returns an array of all platform folder names
///
/// The platform to get the included folder names for
/// All platform folder names
public static string[] GetIncludedFolderNames(UnrealTargetPlatform Platform)
{
UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform);
return BuildPlatform.GetIncludedFolderNames().ToArray();
}
///
/// Returns all the excluded folder names for a given platform
///
/// The platform to get the excluded folder names for
/// Array of folder names
public static string[] GetExcludedFolderNames(UnrealTargetPlatform Platform)
{
UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform);
return BuildPlatform.GetExcludedFolderNames().ToArray();
}
///
/// Check whether the given platform supports XGE
///
/// Platform to check
/// Logger for output
/// True if the platform supports XGE
public static bool CanUseXGE(UnrealTargetPlatform Platform, ILogger Logger)
{
return UEBuildPlatform.IsPlatformAvailable(Platform) && UEBuildPlatform.GetBuildPlatform(Platform).CanUseXGE() && XGE.IsAvailable(Logger);
}
///
/// Check whether the given platform supports the parallel executor in UAT
///
/// Platform to check
/// Logger for output
/// True if the platform supports the parallel executor in UAT
[Obsolete]
public static bool CanUseParallelExecutor(UnrealTargetPlatform Platform, ILogger Logger)
{
return true;
}
///
/// Gets the path for the XGE console executable
///
/// On success, receives the path to the XGE console executable
/// True if the path was found, false otherwise
public static bool TryGetXgConsoleExecutable(out string? OutXgConsoleExe)
{
if (!OperatingSystem.IsWindows())
{
OutXgConsoleExe = null;
return false;
}
return XGE.TryGetXgConsoleExecutable(out OutXgConsoleExe);
}
///
///
///
public static void PreventAutoSDKSwitching()
{
UEBuildPlatformSDK.bAllowAutoSDKSwitching = false;
}
///
///
///
///
public static void SetRemoteIniPath(string Path)
{
UnrealBuildTool.SetRemoteIniPath(Path);
}
///
/// Initialize UBT in the context of another host process (presumably UAT)
///
/// Command Line arguments that UBT may need access to for initializing platforms
/// Logger for output
/// True if initialization was successful
public static bool Initialize(string[] CommandLineArgs, ILogger Logger)
{
// Read the XML configuration files
XmlConfig.ReadConfigFiles(null, null, Logger);
// Register all the platform classes
UEBuildPlatform.RegisterPlatforms(false, false, CommandLineArgs, Logger);
return true;
}
}
}