// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Threading.Tasks; using EpicGames.Core; using Microsoft.Extensions.Logging; namespace UnrealBuildTool { /// /// Systems that need to be configured to execute a tool mode /// [Flags] enum ToolModeOptions { /// /// Do not initialize anything /// None = 0, /// /// Start prefetching metadata for the engine folder as early as possible /// StartPrefetchingEngine = 1, /// /// Initializes the XmlConfig system /// XmlConfig = 2, /// /// Registers build platforms /// BuildPlatforms = 4, /// /// Registers build platforms /// BuildPlatformsHostOnly = 8, /// /// Registers build platforms for validation /// BuildPlatformsForValidation = 16, /// /// Only allow a single instance running in the branch at once /// SingleInstance = 32, /// /// Print out the total time taken to execute /// ShowExecutionTime = 64, /// /// Capture logs as early as possible in a StartupTraceListener object /// UseStartupTraceListener = 128, } /// /// Attribute used to specify options for a UBT mode. /// [AttributeUsage(AttributeTargets.Class)] sealed class ToolModeAttribute : Attribute { /// /// Name of this mode /// public string Name { get; } /// /// Options for executing this mode /// public ToolModeOptions Options { get; } /// /// Constructor /// /// Name of the mode /// Options for this mode public ToolModeAttribute(string name, ToolModeOptions options) { Name = name; Options = options; } } /// /// Base class for standalone UBT modes. Different modes can be invoked using the -Mode=[Name] argument on the command line, where [Name] is determined by /// the ToolModeAttribute on a ToolMode derived class. The log system will be initialized before calling the mode, but little else. /// abstract class ToolMode { /// /// Entry point for this command. /// /// List of command line arguments /// /// Exit code for the process public abstract Task ExecuteAsync(CommandLineArguments Arguments, ILogger Logger); } }