// Copyright Epic Games, Inc. All Rights Reserved. using System.Collections.Generic; using System.Threading.Tasks; using EpicGames.Core; using Microsoft.Extensions.Logging; using OpenTracing.Util; namespace UnrealBuildTool { /// /// Builds a target /// [ToolMode("Execute", ToolModeOptions.XmlConfig | ToolModeOptions.BuildPlatforms | ToolModeOptions.SingleInstance | ToolModeOptions.StartPrefetchingEngine | ToolModeOptions.ShowExecutionTime)] class ExecuteMode : ToolMode { /// /// Whether we should just export the outdated actions list /// [CommandLine("-Actions=", Required = true)] public FileReference? ActionsFile = null; /// /// Main entry point /// /// Command-line arguments /// One of the values of ECompilationResult /// public override async Task ExecuteAsync(CommandLineArguments Arguments, ILogger Logger) { Arguments.ApplyTo(this); // Read the XML configuration files XmlConfig.ApplyTo(this); // Create the build configuration object, and read the settings BuildConfiguration BuildConfiguration = new BuildConfiguration(); XmlConfig.ApplyTo(BuildConfiguration); Arguments.ApplyTo(BuildConfiguration); // Read the actions file List Actions; using (GlobalTracer.Instance.BuildSpan("ActionGraph.ReadActions()").StartActive()) { Actions = ActionGraph.ImportJson(ActionsFile!).ConvertAll(x => new LinkedAction(x, null)); } // Link the action graph using (GlobalTracer.Instance.BuildSpan("ActionGraph.Link()").StartActive()) { ActionGraph.Link(Actions, Logger); } // Execute the actions using (GlobalTracer.Instance.BuildSpan("ActionGraph.ExecuteActions()").StartActive()) { List TargetDescriptors = TargetDescriptor.ParseCommandLine(Arguments, BuildConfiguration, Logger); ActionGraph.CreateDirectoriesForProducedItems(Actions); await ActionGraph.ExecuteActionsAsync(BuildConfiguration, Actions, TargetDescriptors, Logger); } return 0; } } }