You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* Use object type rather than var * Remove double newlines * Use pattern matching #rnx #preflight 647780095d23eca37d28a387 [CL 25706751 by joe kirchoff in ue5-main branch]
346 lines
17 KiB
C#
346 lines
17 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using EpicGames.Core;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
/// <summary>
|
|
/// Base class for platform-specific project generators
|
|
/// </summary>
|
|
abstract class PlatformProjectGenerator
|
|
{
|
|
public static readonly string DefaultPlatformConfigurationType = "Makefile";
|
|
protected readonly ILogger Logger;
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="Arguments">Command line arguments passed to the project generator</param>
|
|
/// <param name="Logger">Logger for output</param>
|
|
public PlatformProjectGenerator(CommandLineArguments Arguments, ILogger Logger)
|
|
{
|
|
this.Logger = Logger;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Register the platform with the UEPlatformProjectGenerator class
|
|
/// </summary>
|
|
public abstract IEnumerable<UnrealTargetPlatform> GetPlatforms();
|
|
|
|
public virtual void GenerateGameProjectStub(ProjectFileGenerator InGenerator, string InTargetName, string InTargetFilepath, TargetRules InTargetRules,
|
|
List<UnrealTargetPlatform> InPlatforms, List<UnrealTargetConfiguration> InConfigurations)
|
|
{
|
|
// Do nothing
|
|
}
|
|
|
|
public virtual void GenerateGameProperties(UnrealTargetConfiguration Configuration, StringBuilder VCProjectFileContent, TargetType TargetType, DirectoryReference RootDirectory, FileReference TargetFilePath)
|
|
{
|
|
// Do nothing
|
|
}
|
|
|
|
public virtual bool RequiresVSUserFileGeneration()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
///
|
|
/// VisualStudio project generation functions
|
|
///
|
|
/// <summary>
|
|
/// Whether this build platform has native support for VisualStudio
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
|
|
/// <param name="ProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <returns>bool true if native VisualStudio support (or custom VSI) is available</returns>
|
|
public virtual bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat)
|
|
{
|
|
// By default, we assume this is true
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the VisualStudio platform name for this build platform
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
|
|
/// <returns>string The name of the platform that VisualStudio recognizes</returns>
|
|
public virtual string GetVisualStudioPlatformName(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
|
|
{
|
|
// By default, return the platform string
|
|
return InPlatform.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the VisualStudio platform name for this build platform
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
|
|
/// <param name="InProjectDir"> The root directory for the current project</param>
|
|
/// <returns>string The name of the platform that VisualStudio recognizes</returns>
|
|
public virtual string GetVisualStudioPlatformName(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, DirectoryReference InProjectDir)
|
|
{
|
|
// By default, return the project-independent platform string
|
|
return GetVisualStudioPlatformName(InPlatform, InConfiguration);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return whether we need a distinct platform name - for cases where there are two targets of the same VS solution platform
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
|
|
/// <param name="InProjectDir"> The root directory for the current project</param>
|
|
/// <returns>bool</returns>
|
|
public virtual bool RequiresDistinctVisualStudioConfigurationName(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, DirectoryReference InProjectDir)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return project configuration settings that must be included before the default props file for all configurations
|
|
/// </summary>
|
|
/// <param name="InPlatform">The UnrealTargetPlatform being built</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>string The custom configuration section for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetVisualStudioPreDefaultString(UnrealTargetPlatform InPlatform, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return project configuration settings that must be included before the default props file
|
|
/// </summary>
|
|
/// <param name="InPlatform">The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration">The UnrealTargetConfiguration being built</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>string The custom configuration section for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetVisualStudioPreDefaultString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the platform toolset string to write into the project configuration
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
|
|
/// <param name="InProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>string The custom configuration section for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetVisualStudioPlatformToolsetString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return any custom property group lines
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetAdditionalVisualStudioPropertyGroups(UnrealTargetPlatform InPlatform, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return any custom property group lines
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <returns>string The platform configuration type. Defaults to "Makefile" unless overridden</returns>
|
|
public virtual string GetVisualStudioPlatformConfigurationType(UnrealTargetPlatform InPlatform, VCProjectFileFormat InProjectFileFormat)
|
|
{
|
|
return DefaultPlatformConfigurationType;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return any custom paths for VisualStudio this platform requires
|
|
/// This include ReferencePath, LibraryPath, LibraryWPath, IncludePath and ExecutablePath.
|
|
/// </summary>
|
|
/// <param name="InPlatform">The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration">The configuration being built</param>
|
|
/// <param name="TargetType">The type of target (game or program)</param>
|
|
/// <param name="TargetRulesPath">Path to the .target.cs file</param>
|
|
/// <param name="ProjectFilePath"></param>
|
|
/// <param name="NMakeOutputPath"></param>
|
|
/// <param name="InProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>The custom path lines for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetVisualStudioPathsEntries(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return any custom property settings. These will be included in the ImportGroup section
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetVisualStudioImportGroupProperties(UnrealTargetPlatform InPlatform, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return any custom property settings. These will be included right after Global properties to make values available to all other imports.
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetVisualStudioGlobalProperties(UnrealTargetPlatform InPlatform, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return any custom target overrides. These will be included last in the project file so they have the opportunity to override any existing settings.
|
|
/// </summary>
|
|
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
|
|
/// <param name="InProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
/// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual void GetVisualStudioTargetOverrides(UnrealTargetPlatform InPlatform, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return any custom layout directory sections
|
|
/// </summary>
|
|
/// <param name="InPlatform">The UnrealTargetPlatform being built</param>
|
|
/// <param name="InConfiguration">The configuration being built</param>
|
|
/// <param name="InConditionString"></param>
|
|
/// <param name="TargetType">The type of target (game or program)</param>
|
|
/// <param name="InProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <param name="NMakeOutputPath"></param>
|
|
/// <param name="ProjectFilePath"></param>
|
|
/// <param name="TargetRulesPath"></param>
|
|
/// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual string GetVisualStudioLayoutDirSection(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, string InConditionString, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the output manifest section, if required
|
|
/// </summary>
|
|
/// <param name="InPlatform">The UnrealTargetPlatform being built</param>
|
|
/// <param name="TargetType">The type of the target being built</param>
|
|
/// <param name="TargetRulesPath">Path to the .target.cs file</param>
|
|
/// <param name="ProjectFilePath">Path to the project file</param>
|
|
/// <param name="InProjectFileFormat">The visual studio project file format being generated</param>
|
|
/// <returns>The output manifest section for the project file; Empty string if it doesn't require one</returns>
|
|
public virtual string GetVisualStudioOutputManifestSection(UnrealTargetPlatform InPlatform, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, VCProjectFileFormat InProjectFileFormat)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get whether this platform deploys
|
|
/// </summary>
|
|
/// <returns>bool true if the 'Deploy' option should be enabled</returns>
|
|
public virtual bool GetVisualStudioDeploymentEnabled(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the text to insert into the user file for the given platform/configuration/target
|
|
/// </summary>
|
|
/// <param name="InPlatform">The platform being added</param>
|
|
/// <param name="InConfiguration">The configuration being added</param>
|
|
/// <param name="InConditionString">The condition string </param>
|
|
/// <param name="InTargetRules">The target rules </param>
|
|
/// <param name="TargetRulesPath">The target rules path</param>
|
|
/// <param name="ProjectFilePath">The project file path</param>
|
|
/// <returns>The string to append to the user file</returns>
|
|
public virtual string GetVisualStudioUserFileStrings(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration,
|
|
string InConditionString, TargetRules InTargetRules, FileReference TargetRulesPath, FileReference ProjectFilePath)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the text to insert into the user file for the given platform/configuration/target
|
|
/// </summary>
|
|
/// <param name="InPlatform">The platform being added</param>
|
|
/// <param name="InConfiguration">The configuration being added</param>
|
|
/// <param name="InConditionString">The condition string </param>
|
|
/// <param name="InTargetRules">The target rules </param>
|
|
/// <param name="TargetRulesPath">The target rules path</param>
|
|
/// <param name="ProjectFilePath">The project file path</param>
|
|
/// <param name="ProjectName">The name of the project</param>
|
|
/// <param name="ForeignUProjectPath">Path to foreign .uproject file, if any</param>
|
|
/// <returns>The string to append to the user file</returns>
|
|
public virtual string GetVisualStudioUserFileStrings(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration,
|
|
string InConditionString, TargetRules InTargetRules, FileReference TargetRulesPath, FileReference ProjectFilePath, string ProjectName, string? ForeignUProjectPath)
|
|
{
|
|
return GetVisualStudioUserFileStrings(InPlatform, InConfiguration, InConditionString, InTargetRules, TargetRulesPath, ProjectFilePath);
|
|
}
|
|
|
|
/// <summary>
|
|
/// For Additional Project Property files that need to be written out. This is currently used only on Android.
|
|
/// </summary>
|
|
public virtual void WriteAdditionalPropFile()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// For additional Project files (ex. *PROJECTNAME*-AndroidRun.androidproj.user) that needs to be written out. This is currently used only on Android.
|
|
/// </summary>
|
|
/// <param name="ProjectFile">Project file this will be related to</param>
|
|
public virtual void WriteAdditionalProjUserFile(ProjectFile ProjectFile)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// For additional Project files (ex. *PROJECTNAME*-AndroidRun.androidproj) that needs to be written out. This is currently used only on Android.
|
|
/// </summary>
|
|
/// <param name="ProjectFile">Project file this will be related to</param>
|
|
/// <returns>Project file written out, Solution folder it should be put in</returns>
|
|
public virtual Tuple<ProjectFile, string>? WriteAdditionalProjFile(ProjectFile ProjectFile)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the text to insert into the UnrealVS configuration file
|
|
/// </summary>
|
|
public virtual void GetUnrealVSConfigurationEntries(StringBuilder UnrealVSContent)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the text to insert into the Project files as additional build arugments for given platform/configuration
|
|
/// </summary>
|
|
/// <param name="InPlatform">The platform being added</param>
|
|
/// <param name="InConfiguration">The configuration being added</param>
|
|
public virtual string GetExtraBuildArguments(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indicates whether this generator will be emitting additional build targets.
|
|
/// Functionally, it's fine to return true and not return any additional text in GetVisualStudioTargetsString, but doing
|
|
/// so may incur additional cost of preparing data for generation.
|
|
/// </summary>
|
|
/// <param name="InPlatform">The platform being added</param>
|
|
/// <returns>True if Targets will be generate, false otherwise. If true is returned, GetVisualStudioTargetsString will be called next.</returns>
|
|
/// <seealso cref="GetVisualStudioTargetsString"/>
|
|
public virtual bool HasVisualStudioTargets(UnrealTargetPlatform InPlatform)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the text to insert into the Project files as additional build targets for the given platform.
|
|
/// </summary>
|
|
/// <param name="InPlatform">The platform being added</param>
|
|
/// <param name="InPlatformConfigurations">List of build configurations for the platform</param>
|
|
/// <param name="ProjectFileBuilder">String builder for the project file</param>
|
|
public virtual void GetVisualStudioTargetsString(UnrealTargetPlatform InPlatform, List<ProjectBuildConfiguration> InPlatformConfigurations, StringBuilder ProjectFileBuilder)
|
|
{
|
|
}
|
|
}
|
|
}
|