2019-12-26 23:01:54 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-01-02 15:30:26 -05:00
|
|
|
|
|
|
|
|
using System;
|
2016-12-13 11:58:16 -05:00
|
|
|
using System.Linq;
|
2020-12-21 23:07:37 -04:00
|
|
|
using EpicGames.Core;
|
2016-12-13 11:58:16 -05:00
|
|
|
|
|
|
|
|
namespace UnrealBuildTool
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Information about a target, passed along when creating a module descriptor
|
|
|
|
|
/// </summary>
|
2018-01-11 16:07:16 -05:00
|
|
|
public class TargetInfo
|
2016-12-13 11:58:16 -05:00
|
|
|
{
|
2017-01-30 16:52:08 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Name of the target
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly string Name;
|
|
|
|
|
|
2016-12-13 11:58:16 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// The platform that the target is being built for
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly UnrealTargetPlatform Platform;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The configuration being built
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly UnrealTargetConfiguration Configuration;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-01-24 09:30:28 -05:00
|
|
|
/// Architecture that the target is being built for
|
2016-12-13 11:58:16 -05:00
|
|
|
/// </summary>
|
2023-01-24 09:30:28 -05:00
|
|
|
public readonly UnrealArchitectures Architectures;
|
2016-12-13 11:58:16 -05:00
|
|
|
|
2023-07-21 12:08:09 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Intermediate environment. Determines if the intermediates end up in a different folder than normal.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public UnrealIntermediateEnvironment IntermediateEnvironment;
|
|
|
|
|
|
2017-01-30 16:52:08 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// The project containing the target
|
|
|
|
|
/// </summary>
|
2020-12-20 18:47:42 -04:00
|
|
|
public readonly FileReference? ProjectFile;
|
2017-01-30 16:52:08 -05:00
|
|
|
|
2018-01-11 16:07:16 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// The current build version
|
|
|
|
|
/// </summary>
|
2023-05-30 18:01:50 -04:00
|
|
|
public ReadOnlyBuildVersion Version => ReadOnlyBuildVersion.Current;
|
2018-01-11 16:07:16 -05:00
|
|
|
|
2019-09-26 09:49:06 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Additional command line arguments for this target
|
|
|
|
|
/// </summary>
|
2020-12-20 18:47:42 -04:00
|
|
|
public CommandLineArguments? Arguments;
|
2019-09-26 09:49:06 -04:00
|
|
|
|
2016-12-13 11:58:16 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a TargetInfo for passing to the TargetRules constructor.
|
|
|
|
|
/// </summary>
|
2017-01-30 16:52:08 -05:00
|
|
|
/// <param name="Name">Name of the target being built</param>
|
2016-12-13 11:58:16 -05:00
|
|
|
/// <param name="Platform">The platform that the target is being built for</param>
|
|
|
|
|
/// <param name="Configuration">The configuration being built</param>
|
2023-01-24 09:30:28 -05:00
|
|
|
/// <param name="Architectures">The architectures being built for</param>
|
2017-01-30 16:52:08 -05:00
|
|
|
/// <param name="ProjectFile">Path to the project file containing the target</param>
|
2019-09-26 09:49:06 -04:00
|
|
|
/// <param name="Arguments">Additional command line arguments for this target</param>
|
2023-07-21 12:08:09 -04:00
|
|
|
/// <param name="IntermediateEnvironment">Intermediate environment to use</param>
|
|
|
|
|
public TargetInfo(string Name, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, UnrealArchitectures? Architectures, FileReference? ProjectFile, CommandLineArguments? Arguments, UnrealIntermediateEnvironment IntermediateEnvironment = UnrealIntermediateEnvironment.Default)
|
2016-12-13 11:58:16 -05:00
|
|
|
{
|
2017-01-30 16:52:08 -05:00
|
|
|
this.Name = Name;
|
2016-12-13 11:58:16 -05:00
|
|
|
this.Platform = Platform;
|
|
|
|
|
this.Configuration = Configuration;
|
2023-07-21 12:08:09 -04:00
|
|
|
this.IntermediateEnvironment = IntermediateEnvironment;
|
2017-01-30 16:52:08 -05:00
|
|
|
this.ProjectFile = ProjectFile;
|
2019-09-26 09:49:06 -04:00
|
|
|
this.Arguments = Arguments;
|
2023-01-24 09:30:28 -05:00
|
|
|
|
|
|
|
|
if (Architectures == null)
|
|
|
|
|
{
|
|
|
|
|
this.Architectures = UnrealArchitectureConfig.ForPlatform(Platform).ActiveArchitectures(ProjectFile, Name);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.Architectures = Architectures;
|
|
|
|
|
}
|
2016-12-13 11:58:16 -05:00
|
|
|
}
|
2020-03-12 14:08:52 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Construct a TargetInfo from an archive on disk
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Reader">Archive to read from</param>
|
|
|
|
|
public TargetInfo(BinaryArchiveReader Reader)
|
|
|
|
|
{
|
2023-05-30 18:59:32 -04:00
|
|
|
Name = Reader.ReadString()!;
|
|
|
|
|
Platform = UnrealTargetPlatform.Parse(Reader.ReadString()!);
|
2021-11-18 14:37:34 -05:00
|
|
|
string ConfigurationStr = Reader.ReadString()!;
|
2023-05-30 18:59:32 -04:00
|
|
|
Architectures = new UnrealArchitectures(Reader.ReadArray(() => Reader.ReadString()!)!);
|
|
|
|
|
ProjectFile = Reader.ReadFileReferenceOrNull();
|
2021-11-18 14:37:34 -05:00
|
|
|
string[]? ArgumentStrs = Reader.ReadArray(() => Reader.ReadString()!);
|
2020-03-12 14:08:52 -04:00
|
|
|
|
|
|
|
|
if (!UnrealTargetConfiguration.TryParse(ConfigurationStr, out Configuration))
|
|
|
|
|
{
|
2023-05-30 18:59:32 -04:00
|
|
|
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<UnrealTargetConfiguration>().Select(x => x.ToString()))));
|
2020-03-12 14:08:52 -04:00
|
|
|
}
|
|
|
|
|
|
2023-07-21 12:08:09 -04:00
|
|
|
string? IntermediateEnvironmentStr = Reader.ReadString();
|
|
|
|
|
if (IntermediateEnvironmentStr != null)
|
|
|
|
|
{
|
|
|
|
|
UnrealIntermediateEnvironment.TryParse(IntermediateEnvironmentStr, out IntermediateEnvironment);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
Arguments = ArgumentStrs == null ? null : new CommandLineArguments(ArgumentStrs);
|
2020-03-12 14:08:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Write a TargetInfo to an archive on disk
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Writer">Archive to write to</param>
|
|
|
|
|
public void Write(BinaryArchiveWriter Writer)
|
|
|
|
|
{
|
|
|
|
|
Writer.WriteString(Name);
|
|
|
|
|
Writer.WriteString(Platform.ToString());
|
|
|
|
|
Writer.WriteString(Configuration.ToString());
|
2023-01-24 09:30:28 -05:00
|
|
|
Writer.WriteArray(Architectures.Architectures.ToArray(), Item => Writer.WriteString(Item.ToString()));
|
2020-03-12 14:08:52 -04:00
|
|
|
Writer.WriteFileReference(ProjectFile);
|
2020-12-20 18:47:42 -04:00
|
|
|
Writer.WriteArray(Arguments?.GetRawArray(), Item => Writer.WriteString(Item));
|
2023-07-21 12:08:09 -04:00
|
|
|
Writer.WriteString(IntermediateEnvironment.ToString());
|
2020-03-12 14:08:52 -04:00
|
|
|
}
|
2016-12-13 11:58:16 -05:00
|
|
|
}
|
|
|
|
|
}
|