2022-06-20 16:34:05 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
using System ;
using System.Collections.Generic ;
using System.Diagnostics ;
using System.Diagnostics.CodeAnalysis ;
2023-08-14 18:16:33 -04:00
using System.IO ;
2023-05-30 18:38:07 -04:00
using System.Linq ;
2022-06-20 16:34:05 -04:00
using System.Runtime.Versioning ;
2023-05-30 18:38:07 -04:00
using System.Text ;
using EpicGames.Core ;
2022-06-20 16:34:05 -04:00
using Microsoft.Extensions.Logging ;
2023-05-30 18:38:07 -04:00
using UnrealBuildBase ;
2022-06-20 16:34:05 -04:00
namespace UnrealBuildTool
{
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
partial struct UnrealArch
{
/// <summary>
/// Version of Arm64 that can interop with X64 (Emulation Compatible)
/// </summary>
2024-04-02 20:19:54 -04:00
public static UnrealArch Arm64ec { get ; } = FindOrAddByName ( "arm64ec" , bIsX64 : false ) ;
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
2023-01-25 19:48:06 -05:00
private struct WindowsArchInfo
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
{
2023-01-25 19:48:06 -05:00
public string ToolChain ;
public string LibDir ;
public string SystemLibDir ;
public WindowsArchInfo ( string ToolChain , string LibDir , string SystemLibDir )
{
this . ToolChain = ToolChain ;
this . LibDir = LibDir ;
this . SystemLibDir = SystemLibDir ;
}
}
2023-03-29 21:12:39 -04:00
private static IReadOnlyDictionary < UnrealArch , WindowsArchInfo > WindowsToolchainArchitectures = new Dictionary < UnrealArch , WindowsArchInfo > ( )
2023-01-25 19:48:06 -05:00
{
{ UnrealArch . Arm64 , new WindowsArchInfo ( "arm64" , "arm64" , "arm64" ) } ,
{ UnrealArch . Arm64ec , new WindowsArchInfo ( "arm64" , "x64" , "arm64" ) } ,
{ UnrealArch . X64 , new WindowsArchInfo ( "x64" , "x64" , "x64" ) } ,
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
} ;
2023-01-25 19:48:06 -05:00
/// <summary>
/// Windows-specific tool chain to compile with
/// </summary>
public string WindowsToolChain
{
get
{
2023-05-30 18:59:32 -04:00
if ( WindowsToolchainArchitectures . ContainsKey ( this ) )
{
return WindowsToolchainArchitectures [ this ] . ToolChain ;
}
2023-01-25 19:48:06 -05:00
throw new BuildException ( $"Unknown architecture {ToString()} passed to UnrealArch.WindowsToolChain" ) ;
}
}
/// <summary>
/// Windows-specific lib directory for this architecture
/// </summary>
public string WindowsLibDir
{
get
{
2023-05-30 18:59:32 -04:00
if ( WindowsToolchainArchitectures . ContainsKey ( this ) )
{
return WindowsToolchainArchitectures [ this ] . LibDir ;
}
2023-01-25 19:48:06 -05:00
throw new BuildException ( $"Unknown architecture {ToString()} passed to UnrealArch.WindowsLibDir" ) ;
}
}
/// <summary>
/// Windows-specific system lib directory for this architecture
/// </summary>
public string WindowsSystemLibDir
{
get
{
2023-05-30 18:59:32 -04:00
if ( WindowsToolchainArchitectures . ContainsKey ( this ) )
{
return WindowsToolchainArchitectures [ this ] . SystemLibDir ;
}
2023-01-25 19:48:06 -05:00
throw new BuildException ( $"Unknown architecture {ToString()} passed to UnrealArch.WindowsSystemLibDir" ) ;
}
}
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
/// <summary>
/// Windows-specific low level name for the generic platforms
/// </summary>
public string WindowsName
{
get
{
2023-05-30 18:59:32 -04:00
if ( WindowsToolchainArchitectures . ContainsKey ( this ) )
{
return WindowsToolchainArchitectures [ this ] . ToolChain ;
}
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
throw new BuildException ( $"Unknown architecture {ToString()} passed to UnrealArch.WindowsName" ) ;
}
}
}
2022-06-20 16:34:05 -04:00
/// <summary>
/// Available compiler toolchains on Windows platform
/// </summary>
public enum WindowsCompiler
{
/// <summary>
/// Use the default compiler. A specific value will always be used outside of configuration classes.
/// </summary>
Default ,
/// <summary>
/// Use Clang for Windows, using the clang-cl driver.
/// </summary>
Clang ,
2023-03-13 23:01:50 -04:00
/// <summary>
/// Use the RTFM (Rollback Transactions on Failure Memory) Clang variant for Verse on Windows, using the verse-clang-cl driver.
/// </summary>
ClangRTFM ,
2022-06-20 16:34:05 -04:00
/// <summary>
/// Use the Intel oneAPI C++ compiler
/// </summary>
Intel ,
/// <summary>
/// Visual Studio 2022 (Visual C++ 17.0)
/// </summary>
VisualStudio2022 ,
2024-01-26 17:21:00 -05:00
/// <summary>
/// Unsupported Visual Studio
/// Must be the last entry in WindowsCompiler enum and should only be used in limited circumstances
/// </summary>
[Obsolete("Unsupported Visual Studio WindowsCompiler, do not use this enum")]
VisualStudioUnsupported ,
2022-06-20 16:34:05 -04:00
}
2023-04-20 19:06:12 -04:00
/// <summary>
/// Enum describing the release channel of a compiler
/// </summary>
internal enum WindowsCompilerChannel
{
Latest ,
Preview ,
2023-04-20 19:07:27 -04:00
Experimental ,
2023-06-28 16:29:28 -04:00
Any = Latest | Preview | Experimental
2023-04-20 19:06:12 -04:00
}
2022-06-20 16:34:05 -04:00
/// <summary>
2024-01-26 17:21:00 -05:00
/// Extension methods for WindowsCompiler enum
2022-06-20 16:34:05 -04:00
/// </summary>
public static class WindowsCompilerExtensions
{
/// <summary>
/// Returns if this compiler toolchain based on Clang
/// </summary>
/// <param name="Compiler">The compiler to check</param>
/// <returns>true if Clang based</returns>
public static bool IsClang ( this WindowsCompiler Compiler )
{
2023-03-13 23:01:50 -04:00
return Compiler = = WindowsCompiler . Clang | | Compiler = = WindowsCompiler . ClangRTFM | | Compiler = = WindowsCompiler . Intel ;
2022-06-20 16:34:05 -04:00
}
2023-08-01 16:56:39 -04:00
/// <summary>
/// Returns if this compiler toolchain based on Intel
/// </summary>
/// <param name="Compiler">The compiler to check</param>
/// <returns>true if Intel based</returns>
public static bool IsIntel ( this WindowsCompiler Compiler )
{
return Compiler = = WindowsCompiler . Intel ;
}
2022-06-20 16:34:05 -04:00
/// <summary>
/// Returns if this compiler toolchain based on MSVC
/// </summary>
/// <param name="Compiler">The compiler to check</param>
/// <returns>true if MSVC based</returns>
public static bool IsMSVC ( this WindowsCompiler Compiler )
{
2024-01-26 17:21:00 -05:00
return Compiler > = WindowsCompiler . VisualStudio2022 ;
2022-06-20 16:34:05 -04:00
}
}
/// <summary>
/// Windows-specific target settings
/// </summary>
public class WindowsTargetRules
{
/// <summary>
/// The target rules which owns this object. Used to resolve some properties.
/// </summary>
TargetRules Target ;
2023-09-26 17:42:24 -04:00
/// <summary>
/// If enabled will set the ProductVersion embeded in windows executables and dlls to contain BUILT_FROM_CHANGELIST and BuildVersion
/// Enabled by default for all precompiled and Shipping configurations. Regardless of this setting, the versions from Build.version will be available via the BuildSettings module
/// Note: Embedding these versions will cause resource files to be recompiled whenever changelist is updated which will cause binaries to relink
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "SetResourceVersions")]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-SetResourceVersions")]
[CommandLine("-NoSetResourceVersions", Value = "false")]
public bool bSetResourceVersions
{
get = > bSetResourceVersionPrivate ? ? Target . bPrecompile | | Target . Configuration = = UnrealTargetConfiguration . Shipping ;
set = > bSetResourceVersionPrivate = value ;
}
private bool? bSetResourceVersionPrivate = null ;
2023-07-26 17:44:21 -04:00
/// <summary>
/// If -PGOOptimize is specified but the linker flags have changed since the last -PGOProfile, this will emit a warning and build without PGO instead of failing during link with LNK1268.
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-IgnoreStalePGOData")]
public bool bIgnoreStalePGOData = false ;
2023-02-11 12:38:06 -05:00
/// <summary>
/// If specified along with -PGOProfile, then /FASTGENPROFILE will be used instead of /GENPROFILE. This usually means that the PGO data is generated faster, but the resulting data may not yield as efficient optimizations during -PGOOptimize
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-PGOFastGen")]
public bool bUseFastGenProfile = false ;
2024-03-25 18:58:08 -04:00
/// <summary>
/// If specified along with -PGOOptimize, will use the specified per-merged pgd file instead of the usual pgd file with loose pgc files.
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-PGOMergedPGD")]
public string? PreMergedPgdFilename = null ;
2023-02-11 12:38:06 -05:00
/// <summary>
/// If specified along with -PGOProfile, prevent the usage of extra counters. Please note that by default /FASTGENPROFILE doesnt use extra counters
/// </summary>
2023-12-13 18:12:53 -05:00
/// <seealso href="https://learn.microsoft.com/en-us/cpp/build/reference/genprofile-fastgenprofile-generate-profiling-instrumented-build">genprofile-fastgenprofile-generate-profiling-instrumented-build</seealso>
2023-02-11 12:38:06 -05:00
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-PGONoExtraCounters")]
public bool bPGONoExtraCounters = false ;
2023-12-18 17:29:33 -05:00
/// <summary>
/// If specified along with -PGOProfile, use sample-based PGO instead of instrumented. Currently Intel oneAPI 2024.0+ only.
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-SampleBasedPGO")]
public bool bSampleBasedPGO = false ;
2023-06-19 15:23:59 -04:00
/// <summary>
/// Which level to use for Inline Function Expansion when TargetRules.bUseInlining is enabled
/// </summary>
2023-12-13 18:12:53 -05:00
/// <seealso href="https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion">ob-inline-function-expansion</seealso>
2023-07-20 17:11:52 -04:00
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "InlineFunctionExpansionLevel")]
2023-06-19 15:23:59 -04:00
[XmlConfigFile(Category = "WindowsPlatform")]
public int InlineFunctionExpansionLevel { get ; set ; } = 2 ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Version of the compiler toolchain to use on Windows platform. A value of "default" will be changed to a specific version at UBT start up.
/// </summary>
2022-08-31 18:53:18 -04:00
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "Compiler")]
2022-06-20 16:34:05 -04:00
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-2022", Value = nameof(WindowsCompiler.VisualStudio2022))]
[CommandLine("-Compiler=")]
public WindowsCompiler Compiler = WindowsCompiler . Default ;
2022-09-21 15:46:54 -04:00
/// <summary>
/// Version of the toolchain to use on Windows platform when a non-msvc Compiler is in use, to locate include paths etc.
/// </summary>
2023-07-19 17:25:57 -04:00
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "Toolchain")]
[XmlConfigFile(Category = "WindowsPlatform")]
2023-07-18 17:55:15 -04:00
[CommandLine("-VCToolchain=")]
public WindowsCompiler ToolChain
{
2024-01-26 17:21:00 -05:00
get = > ToolChainPrivate ? ? ( Compiler . IsMSVC ( ) ? Compiler : WindowsPlatform . GetDefaultCompiler ( Target . ProjectFile , Architecture , Target . Logger , true ) ) ;
2023-07-18 17:55:15 -04:00
set = > ToolChainPrivate = value ;
}
private WindowsCompiler ? ToolChainPrivate = null ;
2022-09-21 15:46:54 -04:00
2022-06-20 16:34:05 -04:00
/// <summary>
/// Architecture of Target.
/// </summary>
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
public UnrealArch Architecture
2022-06-20 16:34:05 -04:00
{
get ;
internal set ;
}
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
= UnrealArch . X64 ;
2022-06-20 16:34:05 -04:00
2024-01-29 22:10:58 -05:00
/// <summary>
/// Warning level when reporting toolchains that are not in the preferred version list
/// </summary>
/// <seealso cref="MicrosoftPlatformSDK.PreferredVisualCppVersions"/>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "ToolchainVersionWarningLevel")]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-ToolchainVersionWarningLevel=")]
public WarningLevel ToolchainVersionWarningLevel { get ; set ; } = WarningLevel . Warning ;
2022-06-20 16:34:05 -04:00
/// <summary>
2023-07-18 17:55:15 -04:00
/// The specific compiler version to use. This may be a specific version number (for example, "14.13.26128"), the string "Latest" to select the newest available version, or
2022-06-20 16:34:05 -04:00
/// the string "Preview" to select the newest available preview version. By default, and if it is available, we use the toolchain version indicated by
/// WindowsPlatform.DefaultToolChainVersion (otherwise, we use the latest version).
/// </summary>
2022-08-31 18:53:18 -04:00
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "CompilerVersion")]
2022-06-20 16:34:05 -04:00
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-CompilerVersion")]
public string? CompilerVersion = null ;
2023-07-18 17:55:15 -04:00
/// <summary>
/// The specific msvc toolchain version to use if the compiler is not msvc. This may be a specific version number (for example, "14.13.26128"), the string "Latest" to select the newest available version, or
/// the string "Preview" to select the newest available preview version. By default, and if it is available, we use the toolchain version indicated by
/// WindowsPlatform.DefaultToolChainVersion (otherwise, we use the latest version).
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "ToolchainVersion")]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-VCToolchainVersion")]
public string? ToolchainVersion = null ;
2023-03-03 17:48:52 -05:00
/// <summary>
/// True if /fastfail should be passed to the msvc compiler and linker
/// </summary>
2024-02-01 12:37:34 -05:00
[RequiresUniqueBuildEnvironment]
2023-03-03 17:48:52 -05:00
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bVCFastFail")]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-VCFastFail")]
public bool bVCFastFail = false ;
2023-11-27 19:40:07 -05:00
/// <summary>
/// True if /d2ExtendedWarningInfo should be passed to the compiler and /d2:-ExtendedWarningInfo to the linker
/// </summary>
2024-02-01 12:37:34 -05:00
[RequiresUniqueBuildEnvironment]
2023-11-27 19:40:07 -05:00
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bVCExtendedWarningInfo")]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-VCExtendedWarningInfo")]
2024-04-03 12:22:43 -04:00
[CommandLine("-VCDisableExtendedWarningInfo", Value = "false")]
2024-02-01 12:37:34 -05:00
public bool bVCExtendedWarningInfo = true ;
2023-11-27 19:40:07 -05:00
2023-09-21 17:34:18 -04:00
/// <summary>
/// True if optimizations to reduce the size of debug information should be disabled
/// See https://clang.llvm.org/docs/UsersManual.html#cmdoption-fstandalone-debug for more information
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bClangStandaloneDebug")]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-ClangStandaloneDebug")]
public bool bClangStandaloneDebug = false ;
2022-09-21 18:08:19 -04:00
/// <summary>
2023-12-18 17:29:33 -05:00
/// True if we should use the Clang linker (LLD) when we are compiling with Clang or Intel oneAPI, otherwise we use the MSVC linker.
2022-09-21 18:08:19 -04:00
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bAllowClangLinker")]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-ClangLinker")]
2024-10-01 19:51:00 -04:00
[CommandLine("-NoClangLinker", Value = "false")]
public bool bAllowClangLinker = true ;
2023-05-06 02:07:48 -04:00
2022-06-20 16:34:05 -04:00
/// <summary>
/// The specific Windows SDK version to use. This may be a specific version number (for example, "8.1", "10.0" or "10.0.10150.0"), or the string "Latest", to select the newest available version.
/// By default, and if it is available, we use the Windows SDK version indicated by WindowsPlatform.DefaultWindowsSdkVersion (otherwise, we use the latest version).
/// </summary>
2023-05-06 02:07:48 -04:00
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "WindowsSDKVersion")]
2022-06-20 16:34:05 -04:00
[XmlConfigFile(Category = "WindowsPlatform")]
2023-05-06 02:07:48 -04:00
[CommandLine("-WindowsSDKVersion")]
2022-06-20 16:34:05 -04:00
public string? WindowsSdkVersion = null ;
/// <summary>
/// Value for the WINVER macro, defining the minimum supported Windows version.
/// </summary>
2023-11-03 12:48:54 -04:00
[RequiresUniqueBuildEnvironment]
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "TargetWindowsVersion")]
2024-08-29 14:17:32 -04:00
public int TargetWindowsVersion
{
get = > TargetWindowsVersionPrivate ? ? GetTargetVersionFromPlatformSDK ( ) ;
set = > TargetWindowsVersionPrivate = value ;
}
private int? TargetWindowsVersionPrivate = null ;
private int GetTargetVersionFromPlatformSDK ( )
{
// due to some reflection property walking, this can actually be called with a non-Windows platform
// in which case, just use Win7. This should never matter (but it's hard to skip due to reflection causing it)
if ( ! Target . Platform . IsInGroup ( UnrealPlatformGroup . Windows ) )
{
return 0x601 ;
}
// @todo some MS platforms are setting this hardcoded, they could move to their SDK.json
string Key = Architecture . bIsX64 ? "MinimumWindowsX64TargetVersion" : "MinimumWindowsArm64TargetVersion" ;
UEBuildPlatformSDK SDK = UEBuildPlatformSDK . GetSDKForPlatform ( Target . Platform . ToString ( ) ) ! ;
// the string in the .json will be eg. 0x601, so convert the string from hex
return Convert . ToInt32 ( SDK . GetRequiredVersionFromConfig ( Key ) , 16 ) ;
}
2022-06-20 16:34:05 -04:00
2023-11-03 12:48:54 -04:00
/// <summary>
/// Value for the NTDDI_VERSION macro, defining the minimum supported Windows version.
/// https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers?redirectedfrom=MSDN#macros-for-conditional-declarations
/// </summary>
[RequiresUniqueBuildEnvironment]
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "TargetWindowsMinorVersion")]
public int? TargetWindowsMinorVersion = null ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Enable PIX debugging (automatically disabled in Shipping and Test configs)
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bEnablePIXProfiling")]
public bool bPixProfilingEnabled = true ;
/// <summary>
/// Enable building with the Win10 SDK instead of the older Win8.1 SDK
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bUseWindowsSDK10")]
public bool bUseWindowsSDK10 = false ;
2022-09-06 16:23:06 -04:00
/// <summary>
/// Enable building with the C++/WinRT language projection
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bUseCPPWinRT")]
public bool bUseCPPWinRT = false ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Enables runtime ray tracing support.
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings", "bEnableRayTracing")]
public bool bEnableRayTracing = false ;
/// <summary>
/// The name of the company (author, provider) that created the project.
/// </summary>
[ConfigFile(ConfigHierarchyType.Game, "/Script/EngineSettings.GeneralProjectSettings", "CompanyName")]
public string? CompanyName ;
/// <summary>
/// The project's copyright and/or trademark notices.
/// </summary>
[ConfigFile(ConfigHierarchyType.Game, "/Script/EngineSettings.GeneralProjectSettings", "CopyrightNotice")]
public string? CopyrightNotice ;
/// <summary>
/// The product name.
/// </summary>
[ConfigFile(ConfigHierarchyType.Game, "/Script/EngineSettings.GeneralProjectSettings", "ProjectName")]
public string? ProductName ;
/// <summary>
/// Enables address sanitizer (ASan). Only supported for Visual Studio 2019 16.7.0 and up.
/// </summary>
[XmlConfigFile(Category = "BuildConfiguration", Name = "bEnableAddressSanitizer")]
[CommandLine("-EnableASan")]
public bool bEnableAddressSanitizer = false ;
2023-04-18 20:53:49 -04:00
/// <summary>
/// Enables LibFuzzer. Only supported for Visual Studio 2022 17.0.0 and up.
/// </summary>
[XmlConfigFile(Category = "BuildConfiguration", Name = "bEnableLibFuzzer")]
[CommandLine("-EnableLibFuzzer")]
public bool bEnableLibFuzzer = false ;
2023-03-29 12:19:12 -04:00
/// <summary>
/// Whether .sarif files containing errors and warnings are written alongside each .obj, if supported
/// </summary>
2024-08-21 15:55:41 -04:00
[Obsolete("No longer necessary, .sarif files will always be written")]
public bool bWriteSarif = true ;
2023-03-29 12:19:12 -04:00
2022-06-20 16:34:05 -04:00
/// <summary>
/// Whether we should export a file containing .obj to source file mappings.
/// </summary>
[XmlConfigFile]
[CommandLine("-ObjSrcMap")]
public string? ObjSrcMapFile = null ;
2023-09-19 19:27:00 -04:00
/// <summary>
/// Whether to have the linker or library tool to generate a link repro in the specified directory
/// See https://learn.microsoft.com/en-us/cpp/build/reference/linkrepro for more information
/// </summary>
[CommandLine("-LinkRepro=")]
public string? LinkReproDir = null ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Provides a Module Definition File (.def) to the linker to describe various attributes of a DLL.
/// Necessary when exporting functions by ordinal values instead of by name.
/// </summary>
public string? ModuleDefinitionFile ;
/// <summary>
/// Specifies the path to a manifest file for the linker to embed. Defaults to the manifest in Engine/Build/Windows/Resources. Can be assigned to null
/// if the target wants to specify its own manifest.
/// </summary>
public string? ManifestFile ;
2023-03-03 15:38:39 -05:00
/// <summary>
/// Specifies the path to an .ico file to use as the appliction icon. Can be assigned to null and will default to Engine/Build/Windows/Resources/Default.ico for engine targets or Build/Windows/Application.ico for projects.
/// </summary>
public string? ApplicationIcon ;
2022-06-20 16:34:05 -04:00
/// <summary>
2022-10-22 07:13:31 -04:00
/// Enables strict standard conformance mode (/permissive-).
2022-06-20 16:34:05 -04:00
/// </summary>
2023-10-31 17:04:28 -04:00
[RequiresUniqueBuildEnvironment]
2022-06-20 16:34:05 -04:00
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-Strict")]
2023-07-27 19:47:12 -04:00
public bool bStrictConformanceMode
{
get = > bStrictConformanceModePrivate ? ? Target . DefaultBuildSettings > = BuildSettingsVersion . V4 ;
set = > bStrictConformanceModePrivate = value ;
}
private bool? bStrictConformanceModePrivate ;
2022-10-22 07:13:31 -04:00
/// <summary>
/// Enables updated __cplusplus macro (/Zc:__cplusplus).
/// </summary>
[RequiresUniqueBuildEnvironment]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-UpdatedCPPMacro")]
2022-11-10 01:08:40 -05:00
public bool bUpdatedCPPMacro = true ;
2022-10-22 07:13:31 -04:00
/// <summary>
/// Enables inline conformance (Remove unreferenced COMDAT) (/Zc:inline).
/// </summary>
[RequiresUniqueBuildEnvironment]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-StrictInline")]
public bool bStrictInlineConformance = false ;
/// <summary>
2023-10-31 17:04:28 -04:00
/// Enables new preprocessor conformance (/Zc:preprocessor). This is always enabled for C++20 modules.
2022-10-22 07:13:31 -04:00
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-StrictPreprocessor")]
public bool bStrictPreprocessorConformance = false ;
/// <summary>
/// Enables enum types conformance (/Zc:enumTypes) in VS2022 17.4 Preview 4.0+.
/// </summary>
[RequiresUniqueBuildEnvironment]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-StrictEnumTypes")]
public bool bStrictEnumTypesConformance = false ;
2022-06-20 16:34:05 -04:00
2024-09-11 19:27:09 -04:00
/// <summary>
/// Enables enforcing standard C++ ODR violations (/Zc:checkGwOdr) in VS2022 17.5 Preview 2.0+
/// </summary>
[RequiresUniqueBuildEnvironment]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-StrictODR")]
public bool bStrictODRViolationConformance = false ;
2024-04-05 18:30:06 -04:00
/// <summary>
/// Volatile Metadata is enabled by default and improves x64 emulation on arm64, but may come at a small perfomance cost (/volatileMetadata-).
/// </summary>
[RequiresUniqueBuildEnvironment]
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-DisableVolatileMetadata")]
public bool bDisableVolatileMetadata { get ; set ; } = false ;
2023-08-18 19:35:13 -04:00
/// <summary>
/// Whether to request the linker create a stripped pdb file as part of the build.
/// If enabled the full debug pdb will have the extension .full.pdb
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-StripPrivateSymbols")]
public bool bStripPrivateSymbols = false ;
2024-06-19 17:08:12 -04:00
/// <summary>
/// If you supply -NoDebugInfo, windows platforms still create debug info while linking. Set this to true to not create debug info while linking in this circumstance
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[CommandLine("-NoLinkerDebugInfo")]
public bool bNoLinkerDebugInfo = false ;
2023-08-22 19:00:20 -04:00
/// <summary>
/// Set page size to allow for larger than 4GB PDBs to be generated by the msvc linker.
/// Will default to 16384 for monolithic editor builds.
/// Values should be a power of two such as 4096, 8192, 16384, or 32768
/// </summary>
public uint? PdbPageSize = null ;
2023-06-01 04:30:15 -04:00
/// <summary>
/// Specify an alternate location for the PDB file. This option does not change the location of the generated PDB file,
/// it changes the name that is embedded into the executable. Path can contain %_PDB% which will be expanded to the original
/// PDB file name of the target, without the directory.
/// See https://learn.microsoft.com/en-us/cpp/build/reference/pdbaltpath-use-alternate-pdb-path
/// </summary>
[CommandLine("-PdbAltPath")]
public string? PdbAlternatePath = null ;
2022-06-20 16:34:05 -04:00
/// VS2015 updated some of the CRT definitions but not all of the Windows SDK has been updated to match.
/// Microsoft provides legacy_stdio_definitions library to enable building with VS2015 until they fix everything up.
2023-05-30 18:01:50 -04:00
public bool bNeedsLegacyStdioDefinitionsLib = > Compiler . IsMSVC ( ) | | Compiler . IsClang ( ) ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// The stack size when linking
/// </summary>
[RequiresUniqueBuildEnvironment]
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings")]
public int DefaultStackSize = 12000000 ;
/// <summary>
/// The stack size to commit when linking
/// </summary>
[RequiresUniqueBuildEnvironment]
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings")]
public int DefaultStackSizeCommit ;
2023-09-13 09:25:27 -04:00
/// <summary>
/// Max number of slots FWindowsPlatformTLS::AllocTlsSlot can allocate.
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsRuntimeSettings.WindowsRuntimeSettings")]
public int MaxNumTlsSlots = 0 ;
/// <summary>
/// Max number threads that can use FWindowsPlatformTLS at one time.
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsRuntimeSettings.WindowsRuntimeSettings")]
public int MaxNumThreadsWithTlsSlots = 0 ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Determines the amount of memory that the compiler allocates to construct precompiled headers (/Zm).
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
public int PCHMemoryAllocationFactor = 0 ;
/// <summary>
/// Allow the target to specify extra options for linking that aren't otherwise noted here
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
public string AdditionalLinkerOptions = "" ;
/// <summary>
/// Create an image that can be hot patched (/FUNCTIONPADMIN)
/// </summary>
public bool bCreateHotPatchableImage
{
2023-05-30 18:01:50 -04:00
get = > bCreateHotPatchableImagePrivate ? ? Target . bWithLiveCoding ;
set = > bCreateHotPatchableImagePrivate = value ;
2022-06-20 16:34:05 -04:00
}
private bool? bCreateHotPatchableImagePrivate ;
/// <summary>
/// Strip unreferenced symbols (/OPT:REF)
/// </summary>
public bool bStripUnreferencedSymbols
{
2023-05-30 18:01:50 -04:00
get = > bStripUnreferencedSymbolsPrivate ? ? ( ( Target . Configuration = = UnrealTargetConfiguration . Test | | Target . Configuration = = UnrealTargetConfiguration . Shipping ) & & ! Target . bWithLiveCoding ) ;
set = > bStripUnreferencedSymbolsPrivate = value ;
2022-06-20 16:34:05 -04:00
}
private bool? bStripUnreferencedSymbolsPrivate ;
2023-05-30 18:38:07 -04:00
2022-06-20 16:34:05 -04:00
/// <summary>
/// Merge identical COMDAT sections together (/OPT:ICF)
/// </summary>
public bool bMergeIdenticalCOMDATs
{
2023-05-30 18:01:50 -04:00
get = > bMergeIdenticalCOMDATsPrivate ? ? ( ( Target . Configuration = = UnrealTargetConfiguration . Test | | Target . Configuration = = UnrealTargetConfiguration . Shipping ) & & ! Target . bWithLiveCoding ) ;
set = > bMergeIdenticalCOMDATsPrivate = value ;
2022-06-20 16:34:05 -04:00
}
private bool? bMergeIdenticalCOMDATsPrivate ;
/// <summary>
/// Whether to put global symbols in their own sections (/Gw), allowing the linker to discard any that are unused.
/// </summary>
public bool bOptimizeGlobalData = true ;
2024-03-28 17:29:39 -04:00
/// <summary>
/// Whether to reduce optimizations for huge functions over an instruction threshold to improve compile time
/// https://devblogs.microsoft.com/cppblog/msvc-backend-updates-in-visual-studio-2019-versions-16-3-and-16-4/
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[RequiresUniqueBuildEnvironment]
public bool bReducedOptimizeHugeFunctions = false ;
/// <summary>
/// The instruction threshold to use when reducing optimizations for huge functions, default 20000.
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
[RequiresUniqueBuildEnvironment]
2024-03-28 17:29:54 -04:00
public int ReducedOptimizeHugeFunctionsThreshold = 20000 ;
2024-03-28 17:29:39 -04:00
2022-06-20 16:34:05 -04:00
/// <summary>
/// (Experimental) Appends the -ftime-trace argument to the command line for Clang to output a JSON file containing a timeline for the compile.
/// See http://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/ for more info.
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
public bool bClangTimeTrace = false ;
/// <summary>
/// Outputs compile timing information so that it can be analyzed.
/// </summary>
[XmlConfigFile(Category = "WindowsPlatform")]
public bool bCompilerTrace = false ;
/// <summary>
/// Print out files that are included by each source file
/// </summary>
2024-05-15 14:51:47 -04:00
[Obsolete("Deprecated in UE5.5 - Use bShowIncludes on TargetRules instead.")]
2022-06-20 16:34:05 -04:00
public bool bShowIncludes = false ;
/// <summary>
/// Bundle a working version of dbghelp.dll with the application, and use this to generate minidumps. This works around a bug with the Windows 10 Fall Creators Update (1709)
/// where rich PE headers larger than a certain size would result in corrupt minidumps.
/// </summary>
public bool bUseBundledDbgHelp = true ;
2023-04-18 04:25:20 -04:00
/// <summary>
/// Whether this build will use Microsoft's custom XCurl instead of libcurl
/// Note that XCurl is not part of the normal Windows SDK and will require additional downloads
/// </summary>
2023-09-08 06:50:20 -04:00
[CommandLine("-UseXCurl")]
2023-04-18 04:25:20 -04:00
public bool bUseXCurl = false ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Settings for PVS studio
/// </summary>
public PVSTargetSettings PVS = new PVSTargetSettings ( ) ;
/// <summary>
/// The Visual C++ environment to use for this target. Only initialized after all the target settings are finalized, in ValidateTarget().
/// </summary>
internal VCEnvironment ? Environment ;
/// <summary>
/// Directory containing the NETFXSDK
/// </summary>
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Manually checked")]
public string? NetFxSdkDir
{
get
{
DirectoryReference ? NetFxSdkDir ;
if ( RuntimePlatform . IsWindows & & MicrosoftPlatformSDK . TryGetNetFxSdkInstallDir ( out NetFxSdkDir ) )
{
return NetFxSdkDir . FullName ;
}
return null ;
}
}
/// <summary>
/// Directory containing the DIA SDK
/// </summary>
2023-05-30 18:01:50 -04:00
public string? DiaSdkDir = > MicrosoftPlatformSDK . FindDiaSdkDirs ( Environment ! . ToolChain ) . Select ( x = > x . FullName ) . FirstOrDefault ( ) ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Directory containing the IDE package (Professional, Community, etc...)
/// </summary>
public string? IDEDir
{
get
{
try
{
2023-03-06 14:42:20 -05:00
return MicrosoftPlatformSDK . FindVisualStudioInstallations ( Environment ! . ToolChain , Target . Logger ) . Select ( x = > x . BaseDir . FullName ) . FirstOrDefault ( ) ;
2022-06-20 16:34:05 -04:00
}
2023-05-30 18:38:07 -04:00
catch ( Exception ) // Find function will throw if there is no visual studio installed! This can happen w/ clang builds
2022-06-20 16:34:05 -04:00
{
return null ;
}
}
}
2023-08-14 18:16:33 -04:00
/// <summary>
/// Directory containing ThirdParty DirectX
/// </summary>
public string DirectXDir = > Path . Combine ( Unreal . EngineSourceDirectory . FullName , "ThirdParty" , "Windows" , "DirectX" ) ;
/// <summary>
/// Directory containing ThirdParty DirectX libs
/// </summary>
public string DirectXLibDir = > Path . Combine ( DirectXDir , "Lib" , Target . Architecture . WindowsLibDir ) + "/" ;
/// <summary>
/// Directory containing ThirdParty DirectX dlls
/// </summary>
public string DirectXDllDir = > Path . Combine ( Unreal . EngineDirectory . FullName , "Binaries" , "ThirdParty" , "Windows" , "DirectX" , Target . Architecture . WindowsLibDir ) + "/" ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// When using a Visual Studio compiler, returns the version name as a string
/// </summary>
2024-01-26 17:21:00 -05:00
/// <returns>The Visual Studio compiler version name (e.g. "2022")</returns>
2022-06-20 16:34:05 -04:00
public string GetVisualStudioCompilerVersionName ( )
{
switch ( Compiler )
{
case WindowsCompiler . Clang :
2023-03-13 23:01:50 -04:00
case WindowsCompiler . ClangRTFM :
2022-06-20 16:34:05 -04:00
case WindowsCompiler . Intel :
case WindowsCompiler . VisualStudio2022 :
return "2015" ; // VS2022 is backwards compatible with VS2015 compiler
default :
throw new BuildException ( "Unexpected WindowsCompiler version for GetVisualStudioCompilerVersionName(). Either not using a Visual Studio compiler or switch block needs to be updated" ) ;
}
}
2023-10-03 17:03:41 -04:00
/// <summary>
/// Determines if a given compiler is installed and valid
/// </summary>
/// <param name="Compiler">Compiler to check for</param>
/// <param name="Architecture">Architecture the compiler must support</param>
/// <param name="Logger">Logger for output</param>
/// <returns>True if the given compiler is installed and valid</returns>
public static bool HasValidCompiler ( WindowsCompiler Compiler , UnrealArch Architecture , ILogger Logger )
{
return MicrosoftPlatformSDK . HasValidCompiler ( Compiler , Architecture , Logger ) ;
}
2022-06-20 16:34:05 -04:00
/// <summary>
/// Constructor
/// </summary>
/// <param name="Target">The target rules which owns this object</param>
internal WindowsTargetRules ( TargetRules Target )
{
this . Target = Target ;
2022-12-08 17:28:30 -05:00
string Platform = Target . Platform . ToString ( ) ;
2023-05-30 18:38:07 -04:00
if ( Target . Platform = = UnrealTargetPlatform . Win64 & & ! Target . Architecture . bIsX64 )
2022-12-08 17:28:30 -05:00
{
Platform + = "-arm64" ;
}
ManifestFile = FileReference . Combine ( Unreal . EngineDirectory , "Build" , "Windows" , "Resources" , String . Format ( "Default-{0}.manifest" , Platform ) ) . FullName ;
2022-06-20 16:34:05 -04:00
}
}
/// <summary>
/// Read-only wrapper for Windows-specific target settings
/// </summary>
public class ReadOnlyWindowsTargetRules
{
/// <summary>
/// The private mutable settings object
/// </summary>
private WindowsTargetRules Inner ;
/// <summary>
/// Constructor
/// </summary>
/// <param name="Inner">The settings object to wrap</param>
public ReadOnlyWindowsTargetRules ( WindowsTargetRules Inner )
{
this . Inner = Inner ;
2023-05-30 18:59:32 -04:00
PVS = new ReadOnlyPVSTargetSettings ( Inner . PVS ) ;
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Accessors for fields on the inner TargetRules instance
/// </summary>
#region Read - only accessor properties
2023-05-30 18:38:07 -04:00
#pragma warning disable CS1591
2022-06-20 16:34:05 -04:00
2023-09-26 17:42:24 -04:00
public bool bSetResourceVersions = > Inner . bSetResourceVersions ;
2023-07-26 17:44:21 -04:00
public bool bIgnoreStalePGOData = > Inner . bIgnoreStalePGOData ;
2023-05-30 18:01:50 -04:00
public bool bUseFastGenProfile = > Inner . bUseFastGenProfile ;
2023-02-11 12:38:06 -05:00
2024-03-25 18:58:08 -04:00
public string? PreMergedPgdFilename = > Inner . PreMergedPgdFilename ;
2023-05-30 18:01:50 -04:00
public bool bPGONoExtraCounters = > Inner . bPGONoExtraCounters ;
2023-02-11 12:38:06 -05:00
2023-12-18 17:29:33 -05:00
public bool bSampleBasedPGO = > Inner . bSampleBasedPGO ;
2023-06-19 15:23:59 -04:00
public int InlineFunctionExpansionLevel = > Inner . InlineFunctionExpansionLevel ;
2023-05-30 18:01:50 -04:00
public WindowsCompiler Compiler = > Inner . Compiler ;
2022-06-20 16:34:05 -04:00
2023-07-18 17:55:15 -04:00
public WindowsCompiler ToolChain = > Inner . ToolChain ;
2023-05-30 18:01:50 -04:00
public UnrealArch Architecture = > Inner . Architecture ;
2022-06-20 16:34:05 -04:00
2024-01-29 22:10:58 -05:00
public WarningLevel ToolchainVersionWarningLevel = > Inner . ToolchainVersionWarningLevel ;
2023-05-30 18:01:50 -04:00
public string? CompilerVersion = > Inner . CompilerVersion ;
2022-06-20 16:34:05 -04:00
2023-07-18 17:55:15 -04:00
public string? ToolchainVerison = > Inner . ToolchainVersion ;
2023-05-30 18:01:50 -04:00
public string? WindowsSdkVersion = > Inner . WindowsSdkVersion ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public int TargetWindowsVersion = > Inner . TargetWindowsVersion ;
2022-06-20 16:34:05 -04:00
2023-11-03 12:48:54 -04:00
public int? TargetWindowsMinorVersion = > Inner . TargetWindowsMinorVersion ;
2023-05-30 18:01:50 -04:00
public bool bPixProfilingEnabled = > Inner . bPixProfilingEnabled ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bUseWindowsSDK10 = > Inner . bUseWindowsSDK10 ;
2022-09-06 16:23:06 -04:00
2023-05-30 18:01:50 -04:00
public bool bUseCPPWinRT = > Inner . bUseCPPWinRT ;
2023-03-03 17:48:52 -05:00
2023-05-30 18:01:50 -04:00
public bool bVCFastFail = > Inner . bVCFastFail ;
2022-09-21 18:08:19 -04:00
2023-11-27 19:40:07 -05:00
public bool bVCExtendedWarningInfo = > Inner . bVCExtendedWarningInfo ;
2023-09-21 17:34:18 -04:00
public bool bClangStandaloneDebug = > Inner . bClangStandaloneDebug ;
2023-05-30 18:01:50 -04:00
public bool bAllowClangLinker = > Inner . bAllowClangLinker ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bEnableRayTracing = > Inner . bEnableRayTracing ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string? CompanyName = > Inner . CompanyName ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string? CopyrightNotice = > Inner . CopyrightNotice ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string? ProductName = > Inner . ProductName ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bEnableAddressSanitizer = > Inner . bEnableAddressSanitizer ;
2023-03-29 12:19:12 -04:00
2023-05-30 18:01:50 -04:00
public bool bEnableLibFuzzer = > Inner . bEnableLibFuzzer ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string? ObjSrcMapFile = > Inner . ObjSrcMapFile ;
2022-06-20 16:34:05 -04:00
2023-09-19 19:27:00 -04:00
public string? LinkReproDir = > Inner . LinkReproDir ;
2023-05-30 18:01:50 -04:00
public string? ModuleDefinitionFile = > Inner . ModuleDefinitionFile ;
2023-03-03 15:38:39 -05:00
2023-05-30 18:01:50 -04:00
public string? ManifestFile = > Inner . ManifestFile ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string? ApplicationIcon = > Inner . ApplicationIcon ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bNeedsLegacyStdioDefinitionsLib = > Inner . bNeedsLegacyStdioDefinitionsLib ;
2022-10-22 07:13:31 -04:00
2023-05-30 18:01:50 -04:00
public bool bStrictConformanceMode = > Inner . bStrictConformanceMode ;
2022-10-22 07:13:31 -04:00
2023-05-30 18:01:50 -04:00
public bool bUpdatedCPPMacro = > Inner . bUpdatedCPPMacro ;
2022-10-22 07:13:31 -04:00
2023-05-30 18:01:50 -04:00
public bool bStrictInlineConformance = > Inner . bStrictInlineConformance ;
2022-10-22 07:13:31 -04:00
2023-05-30 18:01:50 -04:00
public bool bStrictPreprocessorConformance = > Inner . bStrictPreprocessorConformance ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bStrictEnumTypesConformance = > Inner . bStrictEnumTypesConformance ;
2022-06-20 16:34:05 -04:00
2024-09-11 19:27:09 -04:00
public bool bStrictODRViolationConformance = > Inner . bStrictODRViolationConformance ;
2024-04-05 18:30:06 -04:00
public bool bDisableVolatileMetadata = > Inner . bDisableVolatileMetadata ;
2023-08-18 19:35:13 -04:00
public bool bStripPrivateSymbols = > Inner . bStripPrivateSymbols ;
2024-06-19 17:08:12 -04:00
public bool bNoLinkerDebugInfo = > Inner . bNoLinkerDebugInfo ;
2023-08-22 19:00:20 -04:00
public uint? PdbPageSize = > Inner . PdbPageSize ;
2023-06-01 04:30:15 -04:00
public string? PdbAlternatePath = > Inner . PdbAlternatePath ;
2023-05-30 18:01:50 -04:00
public int DefaultStackSize = > Inner . DefaultStackSize ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public int DefaultStackSizeCommit = > Inner . DefaultStackSizeCommit ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public int PCHMemoryAllocationFactor = > Inner . PCHMemoryAllocationFactor ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string AdditionalLinkerOptions = > Inner . AdditionalLinkerOptions ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bCreateHotpatchableImage = > Inner . bCreateHotPatchableImage ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bStripUnreferencedSymbols = > Inner . bStripUnreferencedSymbols ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bMergeIdenticalCOMDATs = > Inner . bMergeIdenticalCOMDATs ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bOptimizeGlobalData = > Inner . bOptimizeGlobalData ;
2022-06-20 16:34:05 -04:00
2024-03-28 17:29:39 -04:00
public bool bReducedOptimizeHugeFunctions = > Inner . bReducedOptimizeHugeFunctions ;
2024-03-28 17:29:54 -04:00
public int ReducedOptimizeHugeFunctionsThreshold = > Inner . ReducedOptimizeHugeFunctionsThreshold ;
2024-03-28 17:29:39 -04:00
2023-05-30 18:01:50 -04:00
public bool bClangTimeTrace = > Inner . bClangTimeTrace ;
public bool bCompilerTrace = > Inner . bCompilerTrace ;
2024-05-15 14:51:47 -04:00
[Obsolete("Deprecated in UE5.5 - Use bShowIncludes on TargetRules instead.")]
2023-05-30 18:01:50 -04:00
public bool bShowIncludes = > Inner . bShowIncludes ;
2022-06-20 16:34:05 -04:00
public string GetVisualStudioCompilerVersionName ( )
{
return Inner . GetVisualStudioCompilerVersionName ( ) ;
}
2023-05-30 18:01:50 -04:00
public bool bUseBundledDbgHelp = > Inner . bUseBundledDbgHelp ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public bool bUseXCurl = > Inner . bUseXCurl ;
2023-04-18 04:25:20 -04:00
2022-06-20 16:34:05 -04:00
public ReadOnlyPVSTargetSettings PVS
{
get ; private set ;
}
2023-05-30 18:01:50 -04:00
internal VCEnvironment ? Environment = > Inner . Environment ;
2022-06-20 16:34:05 -04:00
2023-07-18 17:55:15 -04:00
public string? ToolChainDir = > Inner . Environment ? . ToolChainDir . FullName ? ? null ;
2022-06-20 16:34:05 -04:00
2023-07-18 17:55:15 -04:00
public string? ToolChainVersion = > Inner . Environment ? . ToolChainVersion . ToString ( ) ? ? null ;
2022-06-20 16:34:05 -04:00
2023-07-18 17:55:15 -04:00
public string? WindowsSdkDir = > Inner . Environment ? . WindowsSdkDir . ToString ( ) ? ? null ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string? NetFxSdkDir = > Inner . NetFxSdkDir ;
2022-06-20 16:34:05 -04:00
2023-05-30 18:01:50 -04:00
public string? DiaSdkDir = > Inner . DiaSdkDir ;
public string? IDEDir = > Inner . IDEDir ;
2022-06-20 16:34:05 -04:00
2023-08-14 18:16:33 -04:00
public string DirectXDir = > Inner . DirectXDir ;
public string DirectXLibDir = > Inner . DirectXLibDir ;
public string DirectXDllDir = > Inner . DirectXDllDir ;
2023-09-13 09:25:27 -04:00
public int MaxNumTlsSlots = > Inner . MaxNumTlsSlots ;
public int MaxNumThreadsWithTlsSlots = > Inner . MaxNumThreadsWithTlsSlots ;
2023-05-30 18:38:07 -04:00
#pragma warning restore CS1591
2022-06-20 16:34:05 -04:00
#endregion
}
/// <summary>
/// Information about a particular Visual Studio installation
/// </summary>
[DebuggerDisplay("{BaseDir}")]
class VisualStudioInstallation
{
/// <summary>
/// Compiler type
/// </summary>
public WindowsCompiler Compiler { get ; }
/// <summary>
/// Version number for this installation
/// </summary>
public VersionNumber Version { get ; }
/// <summary>
/// Base directory for the installation
/// </summary>
public DirectoryReference BaseDir { get ; }
/// <summary>
2022-09-15 21:22:37 -04:00
/// Whether it's a community edition of Visual Studio.
2022-06-20 16:34:05 -04:00
/// </summary>
2022-09-15 21:22:37 -04:00
public bool bCommunity { get ; }
2022-06-20 16:34:05 -04:00
/// <summary>
2023-04-20 19:06:12 -04:00
/// The release channel of this installation
2022-06-20 16:34:05 -04:00
/// </summary>
2023-04-20 19:06:12 -04:00
public WindowsCompilerChannel ReleaseChannel { get ; }
2022-06-20 16:34:05 -04:00
/// <summary>
/// Constructor
/// </summary>
2023-04-20 19:06:12 -04:00
public VisualStudioInstallation ( WindowsCompiler Compiler , VersionNumber Version , DirectoryReference BaseDir , bool bCommunity , WindowsCompilerChannel ReleaseChannel )
2022-06-20 16:34:05 -04:00
{
this . Compiler = Compiler ;
this . Version = Version ;
this . BaseDir = BaseDir ;
2022-09-15 21:22:37 -04:00
this . bCommunity = bCommunity ;
2023-04-20 19:06:12 -04:00
this . ReleaseChannel = ReleaseChannel ;
2022-06-20 16:34:05 -04:00
}
}
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
class WindowsArchitectureConfig : UnrealArchitectureConfig
{
public WindowsArchitectureConfig ( )
2023-05-30 18:38:07 -04:00
: base ( UnrealArchitectureMode . OneTargetPerArchitecture , new [ ] { UnrealArch . X64 , UnrealArch . Arm64 , UnrealArch . Arm64ec } )
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
{
}
public override UnrealArchitectures ActiveArchitectures ( FileReference ? ProjectFile , string? TargetName )
{
2023-03-27 14:59:08 -04:00
// for now always compile X64 unless overridden on commandline
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
return new UnrealArchitectures ( UnrealArch . X64 ) ;
}
public override bool RequiresArchitectureFilenames ( UnrealArchitectures Architectures )
{
return Architectures . SingleArchitecture ! = UnrealArch . X64 ;
}
2023-08-14 14:20:12 -04:00
public override UnrealArch GetHostArchitecture ( )
{
switch ( System . Runtime . InteropServices . RuntimeInformation . ProcessArchitecture )
{
case System . Runtime . InteropServices . Architecture . Arm64 :
return UnrealArch . Arm64 ;
2024-04-03 12:22:43 -04:00
default :
2023-08-14 14:20:12 -04:00
return UnrealArch . X64 ;
}
}
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
}
2022-06-20 16:34:05 -04:00
class WindowsPlatform : UEBuildPlatform
2023-05-30 18:38:07 -04:00
{
2022-06-20 16:34:05 -04:00
MicrosoftPlatformSDK SDK ;
/// <summary>
/// Constructor
/// </summary>
/// <param name="InPlatform">Creates a windows platform with the given enum value</param>
/// <param name="InSDK">The installed Windows SDK</param>
/// <param name="InLogger">Logger instance</param>
public WindowsPlatform ( UnrealTargetPlatform InPlatform , MicrosoftPlatformSDK InSDK , ILogger InLogger )
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
: this ( InPlatform , InSDK , new WindowsArchitectureConfig ( ) , InLogger )
{
}
/// <summary>
/// Constructor that takes an archConfig (for use by subclasses)
/// </summary>
/// <param name="InPlatform">Creates a windows platform with the given enum value</param>
/// <param name="InSDK">The installed Windows SDK</param>
/// <param name="ArchConfig">Achitecture configuration</param>
/// <param name="InLogger">Logger instance</param>
public WindowsPlatform ( UnrealTargetPlatform InPlatform , MicrosoftPlatformSDK InSDK , UnrealArchitectureConfig ArchConfig , ILogger InLogger )
: base ( InPlatform , InSDK , ArchConfig , InLogger )
2022-06-20 16:34:05 -04:00
{
SDK = InSDK ;
}
/// <summary>
/// Reset a target's settings to the default
/// </summary>
/// <param name="Target"></param>
public override void ResetTarget ( TargetRules Target )
{
base . ResetTarget ( Target ) ;
}
/// <summary>
/// Creates the VCEnvironment object used to control compiling and other tools. Virtual to allow other platforms to override behavior
/// </summary>
/// <param name="Target">Stanard target object</param>
/// <returns></returns>
[SupportedOSPlatform("windows")]
protected virtual VCEnvironment CreateVCEnvironment ( TargetRules Target )
{
2023-07-18 17:55:15 -04:00
return VCEnvironment . Create ( Target . WindowsPlatform . Compiler , Target . WindowsPlatform . ToolChain , Platform , Target . WindowsPlatform . Architecture , Target . WindowsPlatform . CompilerVersion , Target . WindowsPlatform . ToolchainVersion , Target . WindowsPlatform . WindowsSdkVersion , null , Target . WindowsPlatform . bUseCPPWinRT , Target . WindowsPlatform . bAllowClangLinker , Logger ) ;
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Validate a target's settings
/// </summary>
public override void ValidateTarget ( TargetRules Target )
{
if ( Platform = = UnrealTargetPlatform . Win64 )
{
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
Target . WindowsPlatform . Architecture = Target . Architecture ; // == UnrealArch.Default ? UnrealArch.X64 : Target.Architecture;
2022-12-08 17:28:30 -05:00
2023-01-25 19:48:06 -05:00
// Add names of plugins here that are incompatible with arm64ec or arm64
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
bool bCompilingForArm = ! Target . Architecture . bIsX64 ;
2022-12-08 17:28:30 -05:00
if ( bCompilingForArm & & Target . Name ! = "UnrealHeaderTool" )
{
2023-01-25 19:48:06 -05:00
if ( Target . WindowsPlatform . Architecture = = UnrealArch . Arm64ec )
{
Target . DisablePlugins . AddRange ( new string [ ]
{
2023-07-04 13:52:37 -04:00
"Reflex" ,
2023-01-25 19:48:06 -05:00
"VirtualCamera" , // WebRTC currently does not link properly
} ) ;
2024-08-23 14:27:41 -04:00
Target . GlobalDefinitions . Add ( "UE_EXTERNAL_PROFILING_ENABLED=0" ) ;
}
// disbling some plugins until we get arm64 libs
if ( Target . WindowsPlatform . Architecture = = UnrealArch . Arm64 )
{
Target . DisablePlugins . AddRange ( new string [ ]
{
2024-09-10 10:26:02 -04:00
// steamapi
2024-08-23 14:27:41 -04:00
"OnlineSubsystemSteam" ,
2024-09-10 10:26:02 -04:00
"SteamSockets" ,
2024-08-23 14:27:41 -04:00
// WebRTC / VPX
"VirtualCamera" ,
2024-08-28 10:37:07 -04:00
// Boost (some of these may not be needed, but it doesn't hurt to list)
2024-08-23 14:27:41 -04:00
"USDImporter" ,
"ChaosFlesh" ,
2024-08-28 10:37:07 -04:00
"Interchange" ,
"ChaosClothAssetEditor" ,
"GLTFExporter" ,
"InterchangeAudio" ,
"MetaHuman" ,
"DatasmithInterchange" ,
"InterchangeEditor" ,
"MeshPainting" ,
2024-08-23 14:27:41 -04:00
// DVP
"MediaIOFramework" ,
2024-08-28 10:37:07 -04:00
"Composure" ,
// Flite
"TextToSpeech" ,
2024-09-10 10:26:02 -04:00
// EOSSDK
"OnlineSubsystemEOS" ,
"OnlineServicesEOS" ,
// sce lib
"WinDualShock" ,
2024-08-23 14:27:41 -04:00
} ) ;
2024-09-10 10:26:02 -04:00
Target . bCompileCEF3 = false ;
2023-01-25 19:48:06 -05:00
}
2022-12-08 17:28:30 -05:00
Target . DisablePlugins . AddRange ( new string [ ]
{
2023-01-25 19:48:06 -05:00
"OpenImageDenoise" ,
2022-12-08 17:28:30 -05:00
} ) ;
2023-01-25 19:48:06 -05:00
2023-01-04 18:23:39 -05:00
// VTune does not support ARM
Target . GlobalDefinitions . Add ( "UE_EXTERNAL_PROFILING_ENABLED=0" ) ;
2022-12-08 17:28:30 -05:00
}
2022-06-20 16:34:05 -04:00
}
// Disable Simplygon support if compiling against the NULL RHI.
if ( Target . GlobalDefinitions . Contains ( "USE_NULL_RHI=1" ) )
2022-09-20 13:36:56 -04:00
{
2022-06-20 16:34:05 -04:00
Target . bCompileCEF3 = false ;
}
2023-05-30 18:38:07 -04:00
2022-06-20 16:34:05 -04:00
// If clang is selected for static analysis, switch compiler to clang and proceed
// as normal.
2022-07-06 15:06:26 -04:00
if ( Target . StaticAnalyzer = = StaticAnalyzer . Clang )
2022-06-20 16:34:05 -04:00
{
2022-09-20 13:36:56 -04:00
if ( ! Target . WindowsPlatform . Compiler . IsClang ( ) )
{
Target . WindowsPlatform . Compiler = WindowsCompiler . Clang ;
}
2022-07-06 15:06:26 -04:00
Target . StaticAnalyzer = StaticAnalyzer . Default ;
2023-08-23 20:33:44 -04:00
// Clang static analysis requires non unity builds
Target . bUseUnityBuild = false ;
2022-06-20 16:34:05 -04:00
}
2023-05-30 18:38:07 -04:00
else if ( Target . StaticAnalyzer ! = StaticAnalyzer . None & &
Target . StaticAnalyzerOutputType ! = StaticAnalyzerOutputType . Text )
2022-06-20 16:34:05 -04:00
{
Logger . LogInformation ( "Defaulting static analyzer output type to text" ) ;
}
2024-06-21 15:17:59 -04:00
if ( Target . bUseAutoRTFMCompiler )
2023-03-28 15:14:44 -04:00
{
2024-04-12 12:16:55 -04:00
// We check the static analyzer, and only allow using the AutoRTFM compiler if
// we are not doing static analysis, or are explicitly wanting to use clang.
switch ( Target . StaticAnalyzer )
{
default :
break ;
case StaticAnalyzer . None :
case StaticAnalyzer . Clang :
2024-07-26 05:05:12 -04:00
case StaticAnalyzer . Default :
2024-04-12 12:16:55 -04:00
Target . WindowsPlatform . Compiler = WindowsCompiler . ClangRTFM ;
2024-07-29 02:32:30 -04:00
// We always use clang linker with AutoRTFM.
Target . WindowsPlatform . bAllowClangLinker = true ;
2024-04-12 12:16:55 -04:00
break ;
}
2023-03-28 15:14:44 -04:00
}
2022-06-20 16:34:05 -04:00
// Set the compiler version if necessary
if ( Target . WindowsPlatform . Compiler = = WindowsCompiler . Default )
{
2024-01-26 17:21:00 -05:00
Target . WindowsPlatform . Compiler = GetDefaultCompiler ( Target . ProjectFile , Target . WindowsPlatform . Architecture , Logger , ! Platform . IsInGroup ( UnrealPlatformGroup . Microsoft ) ) ;
2022-06-20 16:34:05 -04:00
}
2022-07-21 12:07:06 -04:00
// Disable linking and ignore build outputs if we're using a static analyzer
2022-07-22 12:15:22 -04:00
if ( Target . StaticAnalyzer ! = StaticAnalyzer . None )
2022-06-20 16:34:05 -04:00
{
Target . bDisableLinking = true ;
2022-07-21 12:07:06 -04:00
Target . bIgnoreBuildOutputs = true ;
2023-11-27 19:40:07 -05:00
// Enable extended warnings when analyzing
Target . WindowsPlatform . bVCExtendedWarningInfo = true ;
2022-06-20 16:34:05 -04:00
}
2022-07-21 12:07:06 -04:00
// Disable PCHs for PVS studio analyzer.
if ( Target . StaticAnalyzer = = StaticAnalyzer . PVSStudio )
2022-06-20 16:34:05 -04:00
{
Target . bUsePCHFiles = false ;
}
2023-05-30 18:38:07 -04:00
2023-02-09 22:37:30 -05:00
// Disable chaining PCH files if not using clang
if ( ! Target . WindowsPlatform . Compiler . IsClang ( ) )
{
Target . bChainPCHs = false ;
}
2022-06-20 16:34:05 -04:00
// E&C support.
if ( Target . bSupportEditAndContinue | | Target . bAdaptiveUnityEnablesEditAndContinue )
{
Target . bUseIncrementalLinking = true ;
}
if ( Target . bAdaptiveUnityEnablesEditAndContinue & & ! Target . bAdaptiveUnityDisablesPCH & & ! Target . bAdaptiveUnityCreatesDedicatedPCH )
{
throw new BuildException ( "bAdaptiveUnityEnablesEditAndContinue requires bAdaptiveUnityDisablesPCH or bAdaptiveUnityCreatesDedicatedPCH" ) ;
}
2023-08-22 19:00:20 -04:00
// for monolithic editor builds, add the PDBPAGESIZE option, (VS 16.11, VC toolchain 14.29.30133), but the pdb will be too large without this
// some monolithic game builds could be too large as well, but they can be added in a .Target.cs with:
// TargetRules.WindowsPlatform.PdbPageSize = 8192;
if ( ! Target . WindowsPlatform . PdbPageSize . HasValue & & Target . LinkType = = TargetLinkType . Monolithic & & Target . Type = = TargetType . Editor )
{
Target . WindowsPlatform . PdbPageSize = 16384 ;
}
2022-06-20 16:34:05 -04:00
// If we're using PDB files and PCHs, the generated code needs to be compiled with the same options as the PCH.
if ( ( Target . bUsePDBFiles | | Target . bSupportEditAndContinue ) & & Target . bUsePCHFiles )
{
Target . bDisableDebugInfoForGeneratedCode = false ;
}
Target . bCompileISPC = true ;
2024-06-20 16:33:42 -04:00
if ( OperatingSystem . IsWindows ( ) )
{
// Initialize the VC environment for the target, and set all the version numbers to the concrete values we chose
Target . WindowsPlatform . Environment = CreateVCEnvironment ( Target ) ;
2022-06-20 16:34:05 -04:00
2024-06-20 16:33:42 -04:00
// pull some things from it
Target . WindowsPlatform . Compiler = Target . WindowsPlatform . Environment . Compiler ;
Target . WindowsPlatform . CompilerVersion = Target . WindowsPlatform . Environment . CompilerVersion . ToString ( ) ;
Target . WindowsPlatform . ToolChain = Target . WindowsPlatform . Environment . ToolChain ;
Target . WindowsPlatform . ToolchainVersion = Target . WindowsPlatform . Environment . ToolChainVersion . ToString ( ) ;
Target . WindowsPlatform . WindowsSdkVersion = Target . WindowsPlatform . Environment . WindowsSdkVersion . ToString ( ) ;
2022-06-20 16:34:05 -04:00
2024-06-20 16:33:42 -04:00
ValidateToolchainVersion ( Target ) ;
}
2024-06-19 18:21:48 -04:00
}
static bool _toolchainWarningLogged = false ;
void ValidateToolchainVersion ( TargetRules Target )
{
if ( _toolchainWarningLogged | | Target . WindowsPlatform . Environment = = null )
{
return ;
}
2023-07-18 17:55:15 -04:00
// Ensure we're using a recent enough version of Clang given the MSVC version
2023-08-10 20:21:27 -04:00
if ( Target . WindowsPlatform . Compiler . IsClang ( ) & & ! MicrosoftPlatformSDK . IgnoreToolchainErrors )
2023-07-18 17:55:15 -04:00
{
VersionNumber ClangVersion = Target . WindowsPlatform . Compiler = = WindowsCompiler . Intel ? MicrosoftPlatformSDK . GetClangVersionForIntelCompiler ( Target . WindowsPlatform . Environment . CompilerPath ) : Target . WindowsPlatform . Environment . CompilerVersion ;
VersionNumber MinimumClang = MicrosoftPlatformSDK . GetMinimumClangVersionForVcVersion ( Target . WindowsPlatform . Environment . ToolChainVersion ) ;
if ( ClangVersion < MinimumClang )
{
throw new BuildException ( "MSVC toolchain version {0} requires Clang compiler version {1} or later. The current Clang compiler version was detected as: {2}" , Target . WindowsPlatform . Environment . ToolChainVersion , MinimumClang , ClangVersion ) ;
}
2023-08-10 20:21:27 -04:00
}
2023-07-18 17:55:15 -04:00
2024-01-29 22:10:58 -05:00
if ( Target . WindowsPlatform . ToolchainVersionWarningLevel ! = WarningLevel . Off )
{
if ( ! MicrosoftPlatformSDK . IsPreferredVersion ( Target . WindowsPlatform . Compiler , Target . WindowsPlatform . Environment . CompilerVersion ) )
{
2024-06-19 18:21:48 -04:00
_toolchainWarningLogged = true ;
2024-01-29 22:10:58 -05:00
VersionNumber preferred = MicrosoftPlatformSDK . GetLatestPreferredVersion ( Target . WindowsPlatform . Compiler ) ;
MicrosoftPlatformSDK . DumpAllToolChainInstallations ( Target . WindowsPlatform . Compiler , Target . Architecture , Logger ) ;
if ( Target . WindowsPlatform . ToolchainVersionWarningLevel = = WarningLevel . Error )
{
throw new BuildLogEventException ( "{Compiler} compiler version {Version} is not a preferred version. Please use the latest preferred version {PreferredVersion}" , WindowsPlatform . GetCompilerName ( Target . WindowsPlatform . Compiler ) , Target . WindowsPlatform . Environment . CompilerVersion , preferred ) ;
}
Logger . LogInformation ( "{Compiler} compiler version {Version} is not a preferred version. Please use the latest preferred version {PreferredVersion}" , WindowsPlatform . GetCompilerName ( Target . WindowsPlatform . Compiler ) , Target . WindowsPlatform . Environment . CompilerVersion , preferred ) ;
}
if ( Target . WindowsPlatform . Compiler ! = Target . WindowsPlatform . ToolChain & & ! MicrosoftPlatformSDK . IsPreferredVersion ( Target . WindowsPlatform . ToolChain , Target . WindowsPlatform . Environment . ToolChainVersion ) )
{
2024-06-19 18:21:48 -04:00
_toolchainWarningLogged = true ;
2024-01-29 22:10:58 -05:00
VersionNumber preferred = MicrosoftPlatformSDK . GetLatestPreferredVersion ( Target . WindowsPlatform . ToolChain ) ;
MicrosoftPlatformSDK . DumpAllToolChainInstallations ( Target . WindowsPlatform . ToolChain , Target . Architecture , Logger ) ;
if ( Target . WindowsPlatform . ToolchainVersionWarningLevel = = WarningLevel . Error )
{
throw new BuildLogEventException ( "{Toolchain} toolchain version {Version} is not a preferred version. Please use the latest preferred version {PreferredVersion}" , WindowsPlatform . GetCompilerName ( Target . WindowsPlatform . ToolChain ) , Target . WindowsPlatform . Environment . ToolChainVersion , preferred ) ;
}
Logger . LogInformation ( "{Toolchain} toolchain version {Version} is not a preferred version. Please use a preferred toolchain such as {PreferredVersion}" , WindowsPlatform . GetCompilerName ( Target . WindowsPlatform . ToolChain ) , Target . WindowsPlatform . Environment . ToolChainVersion , preferred ) ;
}
}
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Gets the default compiler which should be used, if it's not set explicitly by the target, command line, or config file.
/// </summary>
/// <returns>The default compiler version</returns>
2023-05-30 18:38:07 -04:00
internal static WindowsCompiler GetDefaultCompiler ( FileReference ? ProjectFile , UnrealArch Architecture , ILogger Logger , bool bSkipWarning = false )
2022-06-20 16:34:05 -04:00
{
// If there's no specific compiler set, try to pick the matching compiler for the selected IDE
if ( ProjectFileGeneratorSettings . Format ! = null )
{
2023-05-30 18:38:07 -04:00
foreach ( ProjectFileFormat Format in ProjectFileGeneratorSettings . ParseFormatList ( ProjectFileGeneratorSettings . Format , Logger ) )
2022-06-20 16:34:05 -04:00
{
2022-11-17 16:58:58 -05:00
if ( Format = = ProjectFileFormat . VisualStudio2022 )
2022-06-20 16:34:05 -04:00
{
return WindowsCompiler . VisualStudio2022 ;
}
2023-05-30 18:38:07 -04:00
}
2022-06-20 16:34:05 -04:00
}
2022-08-29 17:23:39 -04:00
2022-06-20 16:34:05 -04:00
// Also check the default format for the Visual Studio project generator
object? ProjectFormatObject ;
2022-08-29 17:23:39 -04:00
if ( XmlConfig . TryGetValue ( typeof ( VCProjectFileSettings ) , "ProjectFileFormat" , out ProjectFormatObject ) )
2022-06-20 16:34:05 -04:00
{
VCProjectFileFormat ProjectFormat = ( VCProjectFileFormat ) ProjectFormatObject ;
2022-11-17 16:58:58 -05:00
if ( ProjectFormat = = VCProjectFileFormat . VisualStudio2022 )
2022-06-20 16:34:05 -04:00
{
return WindowsCompiler . VisualStudio2022 ;
}
}
// Check the editor settings too
ProjectFileFormat PreferredAccessor ;
2023-05-30 18:38:07 -04:00
if ( ProjectFileGenerator . GetPreferredSourceCodeAccessor ( ProjectFile , out PreferredAccessor ) )
2022-06-20 16:34:05 -04:00
{
2023-05-30 18:38:07 -04:00
if ( PreferredAccessor = = ProjectFileFormat . VisualStudio2022 )
{
return WindowsCompiler . VisualStudio2022 ;
}
2022-06-20 16:34:05 -04:00
}
2022-11-17 16:58:58 -05:00
// Second, default based on what's installed, test for 2022 first
if ( MicrosoftPlatformSDK . HasValidCompiler ( WindowsCompiler . VisualStudio2022 , Architecture , Logger ) )
2022-08-31 19:25:13 -04:00
{
return WindowsCompiler . VisualStudio2022 ;
}
2022-06-20 16:34:05 -04:00
2023-01-30 10:19:03 -05:00
if ( ! bSkipWarning )
2022-08-31 19:25:13 -04:00
{
2024-09-12 16:31:28 -04:00
UEBuildPlatformSDK ? SDK = GetSDK ( UnrealTargetPlatform . Win64 ) ;
string ToolSetWarning = Architecture = = UnrealArch . X64 ?
"MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)" :
"MSVC v143 - VS 2022 C++ ARM64 build tools (Latest)" ;
string MinMsvcVersion = SDK ? . GetVersionNumberFromConfig ( "MinimumVisualCppVersion" ) ? . ToString ( ) ? ? "Latest" ;
string MinVSVersion = SDK ? . GetVersionNumberFromConfig ( "MinimumVisualStudio2022Version" ) ? . ToString ( ) ? ? "Latest" ;
2023-01-30 10:19:03 -05:00
// If we do have a Visual Studio installation, but we're missing just the C++ parts, warn about that.
if ( TryGetVSInstallDirs ( WindowsCompiler . VisualStudio2022 , Logger ) ! = null )
{
2024-09-12 16:31:28 -04:00
Logger . LogWarning ( "Visual Studio 2022 is installed, but is out of date or missing a valid C++ toolchain (minimum version {MinVersion}). Please update Visual Studio 2022 to {MinVSVersion} or later and verify that the \"{Component}\" component is selected in the Visual Studio 2022 installation options." ,
MinMsvcVersion ,
MinVSVersion ,
ToolSetWarning ) ;
2023-01-30 10:19:03 -05:00
}
else
{
2024-09-12 16:31:28 -04:00
Logger . LogWarning ( "No valid Visual C++ toolchain was found (minimum version {MinVersion}). Please download and install Visual Studio 2022 {MinVSVersion} or later and verify that the \"{Component}\" component is selected in the Visual Studio 2022 installation options." ,
MinMsvcVersion ,
MinVSVersion ,
ToolSetWarning ) ;
2023-01-30 10:19:03 -05:00
}
2022-06-20 16:34:05 -04:00
}
2022-11-17 16:58:58 -05:00
// Finally, default to VS2022 anyway
return WindowsCompiler . VisualStudio2022 ;
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Returns the human-readable name of the given compiler
/// </summary>
/// <param name="Compiler">The compiler value</param>
/// <returns>Name of the compiler</returns>
public static string GetCompilerName ( WindowsCompiler Compiler )
{
return MicrosoftPlatformSDK . GetCompilerName ( Compiler ) ;
}
/// <summary>
/// Get the first Visual Studio install directory for the given compiler version. Note that it is possible for the compiler toolchain to be installed without
/// Visual Studio.
/// </summary>
/// <param name="Compiler">Version of the toolchain to look for.</param>
/// <param name="Logger">Logger for output</param>
/// <returns>True if the directory was found, false otherwise.</returns>
public static IEnumerable < DirectoryReference > ? TryGetVSInstallDirs ( WindowsCompiler Compiler , ILogger Logger )
{
List < VisualStudioInstallation > Installations = MicrosoftPlatformSDK . FindVisualStudioInstallations ( Compiler , Logger ) ;
2023-05-30 18:38:07 -04:00
if ( Installations . Count = = 0 )
2022-06-20 16:34:05 -04:00
{
return null ;
}
return Installations . Select ( x = > x . BaseDir ) ;
}
/// <summary>
2023-10-03 17:03:41 -04:00
/// Determines if a given compiler is installed and valid
2022-06-20 16:34:05 -04:00
/// </summary>
/// <param name="Compiler">Compiler to check for</param>
/// <param name="Architecture">Architecture the compiler must support</param>
/// <param name="Logger">Logger for output</param>
2023-10-03 17:03:41 -04:00
/// <returns>True if the given compiler is installed and valid</returns>
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
public static bool HasCompiler ( WindowsCompiler Compiler , UnrealArch Architecture , ILogger Logger )
2022-06-20 16:34:05 -04:00
{
return MicrosoftPlatformSDK . HasCompiler ( Compiler , Architecture , Logger ) ;
}
/// <summary>
/// Determines the directory containing the MSVC toolchain
/// </summary>
/// <param name="Compiler">Major version of the compiler to use</param>
/// <param name="CompilerVersion">The minimum compiler version to use</param>
/// <param name="Architecture">Architecture that is required</param>
/// <param name="Logger">Logger for output</param>
/// <param name="OutToolChainVersion">Receives the chosen toolchain version</param>
/// <param name="OutToolChainDir">Receives the directory containing the toolchain</param>
/// <param name="OutRedistDir">Receives the optional directory containing redistributable components</param>
/// <returns>True if the toolchain directory was found correctly</returns>
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
public static bool TryGetToolChainDir ( WindowsCompiler Compiler , string? CompilerVersion , UnrealArch Architecture , ILogger Logger , [ NotNullWhen ( true ) ] out VersionNumber ? OutToolChainVersion , [ NotNullWhen ( true ) ] out DirectoryReference ? OutToolChainDir , out DirectoryReference ? OutRedistDir )
2022-06-20 16:34:05 -04:00
{
return MicrosoftPlatformSDK . TryGetToolChainDir ( Compiler , CompilerVersion , Architecture , Logger , out OutToolChainVersion , out OutToolChainDir , out OutRedistDir ) ;
}
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
public static string GetArchitectureName ( UnrealArch arch )
2022-06-20 16:34:05 -04:00
{
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
return arch . ToString ( ) ;
2022-12-08 17:28:30 -05:00
}
2022-06-20 16:34:05 -04:00
/// <summary>
/// Determines if a directory contains a valid DIA SDK
/// </summary>
/// <param name="DiaSdkDir">The directory to check</param>
/// <returns>True if it contains a valid DIA SDK</returns>
static bool IsValidDiaSdkDir ( DirectoryReference DiaSdkDir )
{
return FileReference . Exists ( FileReference . Combine ( DiaSdkDir , "bin" , "amd64" , "msdia140.dll" ) ) ;
}
[SupportedOSPlatform("windows")]
public static bool TryGetWindowsSdkDir ( string? DesiredVersion , ILogger Logger , [ NotNullWhen ( true ) ] out VersionNumber ? OutSdkVersion , [ NotNullWhen ( true ) ] out DirectoryReference ? OutSdkDir )
{
return MicrosoftPlatformSDK . TryGetWindowsSdkDir ( DesiredVersion , Logger , out OutSdkVersion , out OutSdkDir ) ;
}
/// <summary>
/// Gets the platform name that should be used.
/// </summary>
public override string GetPlatformName ( )
{
return "Windows" ;
}
/// <summary>
/// If this platform can be compiled with SN-DBS
/// </summary>
public override bool CanUseSNDBS ( )
{
return true ;
}
/// <summary>
/// If this platform can be compiled with FASTBuild
/// </summary>
public override bool CanUseFASTBuild ( )
{
return true ;
}
/// <summary>
/// Determines if the given name is a build product for a target.
/// </summary>
/// <param name="FileName">The name to check</param>
/// <param name="NamePrefixes">Target or application names that may appear at the start of the build product name (eg. "UnrealEditor", "ShooterGameEditor")</param>
/// <param name="NameSuffixes">Suffixes which may appear at the end of the build product name</param>
/// <returns>True if the string matches the name of a build product, false otherwise</returns>
public override bool IsBuildProduct ( string FileName , string [ ] NamePrefixes , string [ ] NameSuffixes )
{
return IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".exe" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".dll" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".dll.response" )
2023-01-27 15:19:25 -05:00
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".dll.rsp" )
2022-06-20 16:34:05 -04:00
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".lib" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".pdb" )
2023-08-18 19:35:13 -04:00
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".full.pdb" )
2022-06-20 16:34:05 -04:00
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".exp" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".obj" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".map" )
2023-07-31 18:02:16 -04:00
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".objpaths" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".natvis" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".natstepfilter" ) ;
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Get the extension to use for the given binary type
/// </summary>
/// <param name="InBinaryType"> The binrary type being built</param>
/// <returns>string The binary extenstion (ie 'exe' or 'dll')</returns>
public override string GetBinaryExtension ( UEBuildBinaryType InBinaryType )
{
switch ( InBinaryType )
{
case UEBuildBinaryType . DynamicLinkLibrary :
return ".dll" ;
case UEBuildBinaryType . Executable :
return ".exe" ;
case UEBuildBinaryType . StaticLibrary :
return ".lib" ;
}
return base . GetBinaryExtension ( InBinaryType ) ;
}
/// <summary>
/// Get the extensions to use for debug info for the given binary type
/// </summary>
/// <param name="Target">The target being built</param>
/// <param name="InBinaryType"> The binary type being built</param>
/// <returns>string[] The debug info extensions (i.e. 'pdb')</returns>
public override string [ ] GetDebugInfoExtensions ( ReadOnlyTargetRules Target , UEBuildBinaryType InBinaryType )
{
switch ( InBinaryType )
{
case UEBuildBinaryType . DynamicLinkLibrary :
case UEBuildBinaryType . Executable :
2023-05-30 18:38:07 -04:00
return new string [ ] { ".pdb" } ;
2022-06-20 16:34:05 -04:00
}
2024-07-23 19:39:24 -04:00
return Array . Empty < string > ( ) ;
2022-06-20 16:34:05 -04:00
}
public override bool HasDefaultBuildConfig ( UnrealTargetPlatform Platform , DirectoryReference ProjectPath )
{
// check the base settings
return base . HasDefaultBuildConfig ( Platform , ProjectPath ) ;
}
/// <summary>
/// Modify the rules for a newly created module, where the target is a different host platform.
/// This is not required - but allows for hiding details of a particular platform.
/// </summary>
/// <param name="ModuleName">The name of the module</param>
/// <param name="Rules">The module rules</param>
/// <param name="Target">The target being build</param>
public override void ModifyModuleRulesForOtherPlatform ( string ModuleName , ModuleRules Rules , ReadOnlyTargetRules Target )
{
}
/// <summary>
/// Gets the application icon for a given project
/// </summary>
/// <param name="ProjectFile">The project file</param>
/// <returns>The icon to use for this project</returns>
public static FileReference GetWindowsApplicationIcon ( FileReference ? ProjectFile )
{
// Check if there's a custom icon
2023-05-30 18:38:07 -04:00
if ( ProjectFile ! = null )
2022-06-20 16:34:05 -04:00
{
FileReference IconFile = FileReference . Combine ( ProjectFile . Directory , "Build" , "Windows" , "Application.ico" ) ;
2023-05-30 18:38:07 -04:00
if ( FileReference . Exists ( IconFile ) )
2022-06-20 16:34:05 -04:00
{
return IconFile ;
}
}
// Otherwise use the default
return FileReference . Combine ( Unreal . EngineDirectory , "Build" , "Windows" , "Resources" , "Default.ico" ) ;
}
/// <summary>
/// Gets the application icon for a given project
/// </summary>
/// <param name="ProjectFile">The project file</param>
/// <returns>The icon to use for this project</returns>
public virtual FileReference GetApplicationIcon ( FileReference ProjectFile )
{
return GetWindowsApplicationIcon ( ProjectFile ) ;
}
/// <summary>
/// Modify the rules for a newly created module, in a target that's being built for this platform.
/// This is not required - but allows for hiding details of a particular platform.
/// </summary>
/// <param name="ModuleName">The name of the module</param>
/// <param name="Rules">The module rules</param>
/// <param name="Target">The target being build</param>
public override void ModifyModuleRulesForActivePlatform ( string ModuleName , ModuleRules Rules , ReadOnlyTargetRules Target )
{
bool bBuildShaderFormats = Target . bForceBuildShaderFormats ;
2023-11-07 14:04:01 -05:00
if ( ! Target . bBuildRequiresCookedData & & Target . Type ! = TargetType . Program )
2022-06-20 16:34:05 -04:00
{
if ( ModuleName = = "TargetPlatform" )
{
bBuildShaderFormats = true ;
}
}
// allow standalone tools to use target platform modules, without needing Engine
if ( ModuleName = = "TargetPlatform" )
{
if ( Target . bForceBuildTargetPlatforms )
{
Rules . DynamicallyLoadedModuleNames . Add ( "WindowsTargetPlatform" ) ;
2024-02-15 11:46:19 -05:00
Rules . DynamicallyLoadedModuleNames . Add ( "WindowsTargetPlatformSettings" ) ;
Rules . DynamicallyLoadedModuleNames . Add ( "WindowsTargetPlatformControls" ) ;
2022-06-20 16:34:05 -04:00
}
if ( bBuildShaderFormats )
{
Rules . DynamicallyLoadedModuleNames . Add ( "ShaderFormatD3D" ) ;
Rules . DynamicallyLoadedModuleNames . Add ( "ShaderFormatOpenGL" ) ;
Rules . DynamicallyLoadedModuleNames . Add ( "ShaderFormatVectorVM" ) ;
Rules . DynamicallyLoadedModuleNames . Remove ( "VulkanRHI" ) ;
Rules . DynamicallyLoadedModuleNames . Add ( "VulkanShaderFormat" ) ;
}
}
// Delay-load D3D12 so we can use the latest features and still run on downlevel versions of the OS
Rules . PublicDelayLoadDLLs . Add ( "d3d12.dll" ) ;
}
/// <summary>
/// Setup the target environment for building
/// </summary>
/// <param name="Target">Settings for the target being compiled</param>
/// <param name="CompileEnvironment">The compile environment for this target</param>
/// <param name="LinkEnvironment">The link environment for this target</param>
public override void SetUpEnvironment ( ReadOnlyTargetRules Target , CppCompileEnvironment CompileEnvironment , LinkEnvironment LinkEnvironment )
{
// @todo Remove this hack to work around broken includes
CompileEnvironment . Definitions . Add ( "NDIS_MINIPORT_MAJOR_VERSION=0" ) ;
CompileEnvironment . Definitions . Add ( "WIN32=1" ) ;
2022-09-06 16:23:06 -04:00
CompileEnvironment . Definitions . Add ( String . Format ( "_WIN32_WINNT=0x{0:X4}" , Target . WindowsPlatform . TargetWindowsVersion ) ) ;
CompileEnvironment . Definitions . Add ( String . Format ( "WINVER=0x{0:X4}" , Target . WindowsPlatform . TargetWindowsVersion ) ) ;
2023-05-30 18:38:07 -04:00
2023-11-03 12:48:54 -04:00
if ( Target . WindowsPlatform . TargetWindowsMinorVersion ! = null )
{
CompileEnvironment . Definitions . Add ( String . Format ( "NTDDI_VERSION=0x{0:X8}" , Target . WindowsPlatform . TargetWindowsMinorVersion ) ) ;
}
2022-06-20 16:34:05 -04:00
CompileEnvironment . Definitions . Add ( "PLATFORM_WINDOWS=1" ) ;
CompileEnvironment . Definitions . Add ( "PLATFORM_MICROSOFT=1" ) ;
2023-02-21 10:56:42 -05:00
string? OverridePlatformHeaderName = GetOverridePlatformHeaderName ( ) ;
if ( ! String . IsNullOrEmpty ( OverridePlatformHeaderName ) )
{
CompileEnvironment . Definitions . Add ( String . Format ( "OVERRIDE_PLATFORM_HEADER_NAME={0}" , OverridePlatformHeaderName ) ) ;
}
2022-06-20 16:34:05 -04:00
2023-06-14 13:05:10 -04:00
if ( Target . IsInPlatformGroup ( UnrealPlatformGroup . Windows ) & & Target . WindowsPlatform . bEnableRayTracing & & Target . Type ! = TargetType . Server )
2022-06-20 16:34:05 -04:00
{
CompileEnvironment . Definitions . Add ( "RHI_RAYTRACING=1" ) ;
}
// Explicitly exclude the MS C++ runtime libraries we're not using, to ensure other libraries we link with use the same
// runtime library as the engine.
bool bUseDebugCRT = Target . Configuration = = UnrealTargetConfiguration . Debug & & Target . bDebugBuildsActuallyUseDebugCRT ;
if ( ! Target . bUseStaticCRT | | bUseDebugCRT )
{
LinkEnvironment . ExcludedLibraries . Add ( "LIBCMT" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "LIBCPMT" ) ;
}
if ( ! Target . bUseStaticCRT | | ! bUseDebugCRT )
{
LinkEnvironment . ExcludedLibraries . Add ( "LIBCMTD" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "LIBCPMTD" ) ;
}
if ( Target . bUseStaticCRT | | bUseDebugCRT )
{
LinkEnvironment . ExcludedLibraries . Add ( "MSVCRT" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "MSVCPRT" ) ;
}
if ( Target . bUseStaticCRT | | ! bUseDebugCRT )
{
LinkEnvironment . ExcludedLibraries . Add ( "MSVCRTD" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "MSVCPRTD" ) ;
}
LinkEnvironment . ExcludedLibraries . Add ( "LIBC" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "LIBCP" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "LIBCD" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "LIBCPD" ) ;
//@todo ATL: Currently, only VSAccessor requires ATL (which is only used in editor builds)
// When compiling games, we do not want to include ATL - and we can't when compiling games
// made with Launcher build due to VS 2012 Express not including ATL.
// If more modules end up requiring ATL, this should be refactored into a BuildTarget flag (bNeedsATL)
// that is set by the modules the target includes to allow for easier tracking.
// Alternatively, if VSAccessor is modified to not require ATL than we should always exclude the libraries.
if ( Target . LinkType = = TargetLinkType . Monolithic & &
( Target . Type = = TargetType . Game | | Target . Type = = TargetType . Client | | Target . Type = = TargetType . Server ) )
{
LinkEnvironment . ExcludedLibraries . Add ( "atl" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "atls" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "atlsd" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "atlsn" ) ;
LinkEnvironment . ExcludedLibraries . Add ( "atlsnd" ) ;
}
// Add the library used for the delayed loading of DLLs.
LinkEnvironment . SystemLibraries . Add ( "delayimp.lib" ) ;
//@todo - remove once FB implementation uses Http module
if ( Target . bCompileAgainstEngine )
{
// link against wininet (used by FBX and Facebook)
LinkEnvironment . SystemLibraries . Add ( "wininet.lib" ) ;
}
// Compile and link with Win32 API libraries.
LinkEnvironment . SystemLibraries . Add ( "rpcrt4.lib" ) ;
//LinkEnvironment.AdditionalLibraries.Add("wsock32.lib");
LinkEnvironment . SystemLibraries . Add ( "ws2_32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "dbghelp.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "comctl32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "Winmm.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "kernel32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "user32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "gdi32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "winspool.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "comdlg32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "advapi32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "shell32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "ole32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "oleaut32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "uuid.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "odbc32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "odbccp32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "netapi32.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "iphlpapi.lib" ) ;
LinkEnvironment . SystemLibraries . Add ( "setupapi.lib" ) ; // Required for access monitor device enumeration
2023-03-07 19:11:45 -05:00
LinkEnvironment . SystemLibraries . Add ( "synchronization.lib" ) ; // Required for WaitOnAddress and WakeByAddressSingle
2022-06-20 16:34:05 -04:00
// Windows 7 Desktop Windows Manager API for Slate Windows Compliance
LinkEnvironment . SystemLibraries . Add ( "dwmapi.lib" ) ;
// IME
LinkEnvironment . SystemLibraries . Add ( "imm32.lib" ) ;
// For 64-bit builds, we'll forcibly ignore a linker warning with DirectInput. This is
// Microsoft's recommended solution as they don't have a fixed .lib for us.
LinkEnvironment . AdditionalArguments + = " /ignore:4078" ;
// Set up default stack size
LinkEnvironment . DefaultStackSize = Target . WindowsPlatform . DefaultStackSize ;
LinkEnvironment . DefaultStackSizeCommit = Target . WindowsPlatform . DefaultStackSizeCommit ;
LinkEnvironment . ModuleDefinitionFile = Target . WindowsPlatform . ModuleDefinitionFile ;
2023-10-10 18:40:01 -04:00
if ( Target . bPGOOptimize | | Target . bPGOProfile )
2022-06-20 16:34:05 -04:00
{
2023-05-17 20:52:54 -04:00
// Win64 PGO folder is Windows, the rest match the platform name
string PGOPlatform = Target . Platform = = UnrealTargetPlatform . Win64 ? "Windows" : Target . Platform . ToString ( ) ;
2022-06-20 16:34:05 -04:00
2023-10-10 18:40:01 -04:00
CompileEnvironment . PGODirectory = DirectoryReference . Combine ( Target . ProjectFile ? . Directory ? ? Unreal . WritableEngineDirectory , "Platforms" , PGOPlatform , "Build" , "PGO" ) . FullName ;
2023-05-30 18:59:32 -04:00
CompileEnvironment . PGOFilenamePrefix = String . Format ( "{0}-{1}-{2}" , Target . Name , Target . Platform , Target . Configuration ) ;
2022-06-20 16:34:05 -04:00
LinkEnvironment . PGODirectory = CompileEnvironment . PGODirectory ;
LinkEnvironment . PGOFilenamePrefix = CompileEnvironment . PGOFilenamePrefix ;
2024-03-25 18:58:08 -04:00
LinkEnvironment . PGOMergedFilenamePrefix = Target . Platform = = UnrealTargetPlatform . Win64 ? Target . WindowsPlatform . PreMergedPgdFilename : null ;
2022-06-20 16:34:05 -04:00
}
2023-09-13 09:25:27 -04:00
CompileEnvironment . Definitions . Add ( "WINDOWS_MAX_NUM_TLS_SLOTS=" + Target . WindowsPlatform . MaxNumTlsSlots . ToString ( ) ) ;
CompileEnvironment . Definitions . Add ( "WINDOWS_MAX_NUM_THREADS_WITH_TLS_SLOTS=" + Target . WindowsPlatform . MaxNumThreadsWithTlsSlots . ToString ( ) ) ;
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Setup the configuration environment for building
/// </summary>
/// <param name="Target"> The target being built</param>
/// <param name="GlobalCompileEnvironment">The global compile environment</param>
/// <param name="GlobalLinkEnvironment">The global link environment</param>
public override void SetUpConfigurationEnvironment ( ReadOnlyTargetRules Target , CppCompileEnvironment GlobalCompileEnvironment , LinkEnvironment GlobalLinkEnvironment )
{
base . SetUpConfigurationEnvironment ( Target , GlobalCompileEnvironment , GlobalLinkEnvironment ) ;
// NOTE: Even when debug info is turned off, we currently force the linker to generate debug info
// anyway on Visual C++ platforms. This will cause a PDB file to be generated with symbols
// for most of the classes and function/method names, so that crashes still yield somewhat
// useful call stacks, even though compiler-generate debug info may be disabled. This gives
// us much of the build-time savings of fully-disabled debug info, without giving up call
// data completely.
2024-06-19 17:08:12 -04:00
if ( ! Target . WindowsPlatform . bNoLinkerDebugInfo )
{
GlobalLinkEnvironment . bCreateDebugInfo = true ;
}
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Whether this platform should create debug information or not
/// </summary>
/// <param name="Target">The target being built</param>
/// <returns>bool true if debug info should be generated, false if not</returns>
public override bool ShouldCreateDebugInfo ( ReadOnlyTargetRules Target )
{
switch ( Target . Configuration )
{
case UnrealTargetConfiguration . Development :
case UnrealTargetConfiguration . Shipping :
case UnrealTargetConfiguration . Test :
return ! Target . bOmitPCDebugInfoInDevelopment ;
case UnrealTargetConfiguration . DebugGame :
case UnrealTargetConfiguration . Debug :
default :
return true ;
2024-04-03 17:18:04 -04:00
}
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Creates a toolchain instance for the given platform.
/// </summary>
/// <param name="Target">The target being built</param>
/// <returns>New toolchain instance.</returns>
public override UEToolChain CreateToolChain ( ReadOnlyTargetRules Target )
{
2023-12-22 16:18:30 -05:00
VCToolChain toolchain = new VCToolChain ( Target , Logger ) ;
2022-07-06 15:06:26 -04:00
if ( Target . StaticAnalyzer = = StaticAnalyzer . PVSStudio )
2022-06-20 16:34:05 -04:00
{
2023-12-22 16:18:30 -05:00
return new PVSToolChain ( Target , toolchain , Logger ) ;
2022-06-20 16:34:05 -04:00
}
2023-12-22 16:18:30 -05:00
return toolchain ;
2022-06-20 16:34:05 -04:00
}
/// <summary>
/// Allows the platform to return various build metadata that is not tracked by other means. If the returned string changes, the makefile will be invalidated.
/// </summary>
/// <param name="ProjectFile">The project file being built</param>
/// <param name="Metadata">String builder to contain build metadata</param>
public override void GetExternalBuildMetadata ( FileReference ? ProjectFile , StringBuilder Metadata )
{
base . GetExternalBuildMetadata ( ProjectFile , Metadata ) ;
2023-05-30 18:38:07 -04:00
if ( ProjectFile ! = null )
2022-06-20 16:34:05 -04:00
{
Metadata . AppendLine ( "ICON: {0}" , GetApplicationIcon ( ProjectFile ) ) ;
}
}
/// <summary>
/// Deploys the given target
/// </summary>
/// <param name="Receipt">Receipt for the target being deployed</param>
public override void Deploy ( TargetReceipt Receipt )
{
new UEDeployWindows ( Logger ) . PrepTargetForDeployment ( Receipt ) ;
}
2023-02-21 10:56:42 -05:00
/// <summary>
/// Allows the platform header name to be overridden to differ from the platform name.
/// </summary>
protected virtual string? GetOverridePlatformHeaderName ( )
{
// Both Win32 and Win64 use Windows headers, so we enforce that here.
return GetPlatformName ( ) ;
}
2022-06-20 16:34:05 -04:00
}
class UEDeployWindows : UEBuildDeploy
{
public UEDeployWindows ( ILogger InLogger )
: base ( InLogger )
{
}
public override bool PrepTargetForDeployment ( TargetReceipt Receipt )
{
return base . PrepTargetForDeployment ( Receipt ) ;
}
}
class WindowsPlatformFactory : UEBuildPlatformFactory
{
2023-05-30 18:01:50 -04:00
public override UnrealTargetPlatform TargetPlatform = > UnrealTargetPlatform . Win64 ;
2022-06-20 16:34:05 -04:00
/// <summary>
/// Register the platform with the UEBuildPlatform class
/// </summary>
public override void RegisterBuildPlatforms ( ILogger Logger )
{
MicrosoftPlatformSDK SDK = new MicrosoftPlatformSDK ( Logger ) ;
// Register this build platform for Win64 (no more Win32)
UEBuildPlatform . RegisterBuildPlatform ( new WindowsPlatform ( UnrealTargetPlatform . Win64 , SDK , Logger ) , Logger ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Win64 , UnrealPlatformGroup . Windows ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Win64 , UnrealPlatformGroup . Microsoft ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Win64 , UnrealPlatformGroup . Desktop ) ;
}
}
}