// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using EpicGames.Core; using UnrealBuildBase; namespace UnrealBuildTool { /// /// Information about a target, passed along when creating a module descriptor /// public class TargetInfo { /// /// Name of the target /// public readonly string Name; /// /// The platform that the target is being built for /// public readonly UnrealTargetPlatform Platform; /// /// The configuration being built /// public readonly UnrealTargetConfiguration Configuration; /// /// Architecture that the target is being built for (or an empty string for the default) /// public readonly string Architecture; /// /// The project containing the target /// public readonly FileReference? ProjectFile; /// /// The current build version /// public ReadOnlyBuildVersion Version { get { return ReadOnlyBuildVersion.Current; } } /// /// Additional command line arguments for this target /// public CommandLineArguments? Arguments; /// /// Constructs a TargetInfo for passing to the TargetRules constructor. /// /// Name of the target being built /// The platform that the target is being built for /// The configuration being built /// The architecture being built for /// Path to the project file containing the target /// Additional command line arguments for this target public TargetInfo(string Name, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string Architecture, FileReference? ProjectFile, CommandLineArguments? Arguments) { this.Name = Name; this.Platform = Platform; this.Configuration = Configuration; this.Architecture = Architecture; this.ProjectFile = ProjectFile; this.Arguments = Arguments; } /// /// Construct a TargetInfo from an archive on disk /// /// Archive to read from public TargetInfo(BinaryArchiveReader Reader) { this.Name = Reader.ReadString()!; this.Platform = UnrealTargetPlatform.Parse(Reader.ReadString()!); string ConfigurationStr = Reader.ReadString()!; this.Architecture = Reader.ReadString()!; this.ProjectFile = Reader.ReadFileReferenceOrNull(); string[]? ArgumentStrs = Reader.ReadArray(() => Reader.ReadString()!); if (!UnrealTargetConfiguration.TryParse(ConfigurationStr, out Configuration)) { throw new BuildException(string.Format("The configration name {0} is not a valid configration name. Valid names are ({1})", Name, string.Join(",", Enum.GetValues(typeof(UnrealTargetConfiguration)).Cast().Select(x => x.ToString())))); } Arguments = ArgumentStrs == null ? null : new CommandLineArguments(ArgumentStrs); } /// /// Write a TargetInfo to an archive on disk /// /// Archive to write to public void Write(BinaryArchiveWriter Writer) { Writer.WriteString(Name); Writer.WriteString(Platform.ToString()); Writer.WriteString(Configuration.ToString()); Writer.WriteString(Architecture); Writer.WriteFileReference(ProjectFile); Writer.WriteArray(Arguments?.GetRawArray(), Item => Writer.WriteString(Item)); } } }