// 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 { /// /// Base class for platform-specific project generators /// abstract class PlatformProjectGenerator { public static readonly string DefaultPlatformConfigurationType = "Makefile"; protected readonly ILogger Logger; /// /// Constructor /// /// Command line arguments passed to the project generator /// Logger for output public PlatformProjectGenerator(CommandLineArguments Arguments, ILogger Logger) { this.Logger = Logger; } /// /// Register the platform with the UEPlatformProjectGenerator class /// public abstract IEnumerable GetPlatforms(); public virtual void GenerateGameProjectStub(ProjectFileGenerator InGenerator, string InTargetName, string InTargetFilepath, TargetRules InTargetRules, List InPlatforms, List 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 /// /// /// Whether this build platform has native support for VisualStudio /// /// The UnrealTargetPlatform being built /// The UnrealTargetConfiguration being built /// The visual studio project file format being generated /// bool true if native VisualStudio support (or custom VSI) is available public virtual bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat) { // By default, we assume this is true return true; } /// /// Return the VisualStudio platform name for this build platform /// /// The UnrealTargetPlatform being built /// The UnrealTargetConfiguration being built /// string The name of the platform that VisualStudio recognizes public virtual string GetVisualStudioPlatformName(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration) { // By default, return the platform string return InPlatform.ToString(); } /// /// Return the VisualStudio platform name for this build platform /// /// The UnrealTargetPlatform being built /// The UnrealTargetConfiguration being built /// The root directory for the current project /// string The name of the platform that VisualStudio recognizes public virtual string GetVisualStudioPlatformName(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, DirectoryReference InProjectDir) { // By default, return the project-independent platform string return GetVisualStudioPlatformName(InPlatform, InConfiguration); } /// /// Return whether we need a distinct platform name - for cases where there are two targets of the same VS solution platform /// /// The UnrealTargetPlatform being built /// The UnrealTargetConfiguration being built /// The root directory for the current project /// bool public virtual bool RequiresDistinctVisualStudioConfigurationName(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, DirectoryReference InProjectDir) { return false; } /// /// Return project configuration settings that must be included before the default props file for all configurations /// /// The UnrealTargetPlatform being built /// String builder for the project file /// string The custom configuration section for the project file; Empty string if it doesn't require one public virtual void GetVisualStudioPreDefaultString(UnrealTargetPlatform InPlatform, StringBuilder ProjectFileBuilder) { } /// /// Return project configuration settings that must be included before the default props file /// /// The UnrealTargetPlatform being built /// The UnrealTargetConfiguration being built /// String builder for the project file /// string The custom configuration section for the project file; Empty string if it doesn't require one public virtual void GetVisualStudioPreDefaultString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, StringBuilder ProjectFileBuilder) { } /// /// Return the platform toolset string to write into the project configuration /// /// The UnrealTargetPlatform being built /// The UnrealTargetConfiguration being built /// The visual studio project file format being generated /// String builder for the project file /// string The custom configuration section for the project file; Empty string if it doesn't require one public virtual void GetVisualStudioPlatformToolsetString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder) { } /// /// Return any custom property group lines /// /// The UnrealTargetPlatform being built /// The visual studio project file format being generated /// String builder for the project file /// string The custom property import lines for the project file; Empty string if it doesn't require one public virtual void GetAdditionalVisualStudioPropertyGroups(UnrealTargetPlatform InPlatform, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder) { } /// /// Return any custom property group lines /// /// The UnrealTargetPlatform being built /// The visual studio project file format being generated /// string The platform configuration type. Defaults to "Makefile" unless overridden public virtual string GetVisualStudioPlatformConfigurationType(UnrealTargetPlatform InPlatform, VCProjectFileFormat InProjectFileFormat) { return DefaultPlatformConfigurationType; } /// /// Return any custom paths for VisualStudio this platform requires /// This include ReferencePath, LibraryPath, LibraryWPath, IncludePath and ExecutablePath. /// /// The UnrealTargetPlatform being built /// The configuration being built /// The type of target (game or program) /// Path to the .target.cs file /// /// /// The visual studio project file format being generated /// String builder for the project file /// The custom path lines for the project file; Empty string if it doesn't require one public virtual void GetVisualStudioPathsEntries(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder) { } /// /// Return any custom property settings. These will be included in the ImportGroup section /// /// The UnrealTargetPlatform being built /// String builder for the project file /// string The custom property import lines for the project file; Empty string if it doesn't require one public virtual void GetVisualStudioImportGroupProperties(UnrealTargetPlatform InPlatform, StringBuilder ProjectFileBuilder) { } /// /// Return any custom property settings. These will be included right after Global properties to make values available to all other imports. /// /// The UnrealTargetPlatform being built /// String builder for the project file /// string The custom property import lines for the project file; Empty string if it doesn't require one public virtual void GetVisualStudioGlobalProperties(UnrealTargetPlatform InPlatform, StringBuilder ProjectFileBuilder) { } /// /// Return any custom target overrides. These will be included last in the project file so they have the opportunity to override any existing settings. /// /// The UnrealTargetPlatform being built /// The visual studio project file format being generated /// String builder for the project file /// string The custom property import lines for the project file; Empty string if it doesn't require one public virtual void GetVisualStudioTargetOverrides(UnrealTargetPlatform InPlatform, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder) { } /// /// Return any custom layout directory sections /// /// The UnrealTargetPlatform being built /// The configuration being built /// /// The type of target (game or program) /// The visual studio project file format being generated /// /// /// /// string The custom property import lines for the project file; Empty string if it doesn't require one public virtual string GetVisualStudioLayoutDirSection(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, string InConditionString, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat) { return ""; } /// /// Get the output manifest section, if required /// /// The UnrealTargetPlatform being built /// The type of the target being built /// Path to the .target.cs file /// Path to the project file /// The visual studio project file format being generated /// The output manifest section for the project file; Empty string if it doesn't require one public virtual string GetVisualStudioOutputManifestSection(UnrealTargetPlatform InPlatform, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, VCProjectFileFormat InProjectFileFormat) { return ""; } /// /// Get whether this platform deploys /// /// bool true if the 'Deploy' option should be enabled public virtual bool GetVisualStudioDeploymentEnabled(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration) { return false; } /// /// Get the text to insert into the user file for the given platform/configuration/target /// /// The platform being added /// The configuration being added /// The condition string /// The target rules /// The target rules path /// The project file path /// The string to append to the user file public virtual string GetVisualStudioUserFileStrings(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, string InConditionString, TargetRules InTargetRules, FileReference TargetRulesPath, FileReference ProjectFilePath) { return ""; } /// /// Get the text to insert into the user file for the given platform/configuration/target /// /// The platform being added /// The configuration being added /// The condition string /// The target rules /// The target rules path /// The project file path /// The name of the project /// Path to foreign .uproject file, if any /// The string to append to the user file 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); } /// /// For Additional Project Property files that need to be written out. This is currently used only on Android. /// public virtual void WriteAdditionalPropFile() { } /// /// For additional Project files (ex. *PROJECTNAME*-AndroidRun.androidproj.user) that needs to be written out. This is currently used only on Android. /// /// Project file this will be related to public virtual void WriteAdditionalProjUserFile(ProjectFile ProjectFile) { } /// /// For additional Project files (ex. *PROJECTNAME*-AndroidRun.androidproj) that needs to be written out. This is currently used only on Android. /// /// Project file this will be related to /// Project file written out, Solution folder it should be put in public virtual Tuple? WriteAdditionalProjFile(ProjectFile ProjectFile) { return null; } /// /// Gets the text to insert into the UnrealVS configuration file /// public virtual void GetUnrealVSConfigurationEntries(StringBuilder UnrealVSContent) { } /// /// Gets the text to insert into the Project files as additional build arugments for given platform/configuration /// /// The platform being added /// The configuration being added public virtual string GetExtraBuildArguments(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration) { return ""; } /// /// 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. /// /// The platform being added /// True if Targets will be generate, false otherwise. If true is returned, GetVisualStudioTargetsString will be called next. /// public virtual bool HasVisualStudioTargets(UnrealTargetPlatform InPlatform) { return false; } /// /// Get the text to insert into the Project files as additional build targets for the given platform. /// /// The platform being added /// List of build configurations for the platform /// String builder for the project file public virtual void GetVisualStudioTargetsString(UnrealTargetPlatform InPlatform, List InPlatformConfigurations, StringBuilder ProjectFileBuilder) { } } }