2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
using System ;
using System.Collections.Generic ;
using System.Text ;
using System.Diagnostics ;
using System.IO ;
using Microsoft.Win32 ;
2015-01-28 08:26:51 -05:00
using System.Linq ;
2014-03-14 14:13:41 -04:00
namespace UnrealBuildTool
{
2014-07-18 14:21:02 -04:00
/// <summary>
/// Available compiler toolchains on Windows platform
/// </summary>
public enum WindowsCompiler
{
2015-01-08 09:02:37 -05:00
/// Visual Studio 2012 (Visual C++ 11.0). No longer supported for building on Windows, but required for other platform toolchains.
2014-07-18 14:21:02 -04:00
VisualStudio2012 ,
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/// Visual Studio 2013 (Visual C++ 12.0)
VisualStudio2013 ,
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
public class WindowsPlatform : UEBuildPlatform
{
/// Property caching.
private static WindowsCompiler ? CachedCompiler ;
2014-06-26 06:00:21 -04:00
2014-07-18 14:21:02 -04:00
/// Version of the compiler toolchain to use on Windows platform
public static WindowsCompiler Compiler
{
get
{
// Cache the result because Compiler is often used.
if ( CachedCompiler . HasValue )
{
return CachedCompiler . Value ;
}
2014-06-26 06:00:21 -04:00
2014-07-18 14:21:02 -04:00
// First check if Visual Sudio 2013 is installed.
if ( ! String . IsNullOrEmpty ( WindowsPlatform . GetVSComnToolsPath ( WindowsCompiler . VisualStudio2013 ) ) )
{
CachedCompiler = WindowsCompiler . VisualStudio2013 ;
}
// Finally assume 2013 is installed to defer errors somewhere else like VCToolChain
else
{
CachedCompiler = WindowsCompiler . VisualStudio2013 ;
}
2014-06-26 06:00:21 -04:00
2014-07-18 14:21:02 -04:00
return CachedCompiler . Value ;
}
}
2014-03-14 14:13:41 -04:00
2015-04-28 10:53:30 -04:00
/// <summary>
/// When true, throws some CL and link flags (/Bt+ and /link) to output detailed timing info.
/// </summary>
[XmlConfig]
public static bool bLogDetailedCompilerTimingInfo = false ;
2014-12-18 16:52:27 -05:00
/// True if we should use Clang/LLVM instead of MSVC to compile code on Windows platform
2014-07-18 14:21:02 -04:00
public static readonly bool bCompileWithClang = false ;
2014-08-15 16:13:57 -04:00
2014-12-18 16:52:27 -05:00
/// When using Clang, enabling enables the MSVC-like "clang-cl" wrapper, otherwise we pass arguments to Clang directly
2015-03-27 16:44:10 -04:00
public static readonly bool bUseVCCompilerArgs = ! bCompileWithClang | | false ;
2014-12-18 16:52:27 -05:00
2014-08-15 16:13:57 -04:00
/// True if we should use the Clang linker (LLD) when bCompileWithClang is enabled, otherwise we use the MSVC linker
2014-12-18 16:52:27 -05:00
public static readonly bool bAllowClangLinker = bCompileWithClang & & true ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/// True if we're targeting Windows XP as a minimum spec. In Visual Studio 2012 and higher, this may change how
/// we compile and link the application (http://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx)
2015-01-28 08:26:51 -05:00
/// This is a flag to determine we should support XP if possible from XML
2014-07-18 14:21:02 -04:00
[XmlConfig]
2015-01-28 08:26:51 -05:00
public static bool SupportWindowsXPIfAvailable = false ;
private static bool SupportWindowsXP ;
public static bool IsWindowsXPSupported ( )
{
return SupportWindowsXP ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/** True if VS EnvDTE is available (false when building using Visual Studio Express) */
public static bool bHasVisualStudioDTE
{
get
{
2014-09-04 13:15:42 -04:00
// @todo clang: DTE #import doesn't work with Clang compiler
if ( bCompileWithClang )
{
return false ;
}
2014-07-18 14:21:02 -04:00
try
{
// Interrogate the Win32 registry
2014-04-02 18:09:23 -04:00
string DTEKey = ( Compiler = = WindowsCompiler . VisualStudio2013 ) ? "VisualStudio.DTE.12.0" : "VisualStudio.DTE.11.0" ;
return RegistryKey . OpenBaseKey ( RegistryHive . ClassesRoot , RegistryView . Registry32 ) . OpenSubKey ( DTEKey ) ! = null ;
2014-07-18 14:21:02 -04:00
}
catch ( Exception )
{
return false ;
}
}
}
2014-03-14 14:13:41 -04:00
2015-01-28 08:26:51 -05:00
/** The current architecture */
public override string GetActiveArchitecture ( )
{
return IsWindowsXPSupported ( ) ? "_XP" : base . GetActiveArchitecture ( ) ;
}
2014-07-18 14:21:02 -04:00
protected override SDKStatus HasRequiredManualSDKInternal ( )
{
return SDKStatus . Valid ;
}
2014-04-29 21:56:53 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Returns VisualStudio common tools path for current compiler .
*
* @return Common tools path .
* /
public static string GetVSComnToolsPath ( )
{
return GetVSComnToolsPath ( Compiler ) ;
}
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Returns VisualStudio common tools path for given compiler .
*
* @param Compiler Compiler for which to return tools path .
*
* @return Common tools path .
* /
public static string GetVSComnToolsPath ( WindowsCompiler Compiler )
{
int VSVersion ;
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
switch ( Compiler )
{
case WindowsCompiler . VisualStudio2012 :
VSVersion = 11 ;
break ;
case WindowsCompiler . VisualStudio2013 :
VSVersion = 12 ;
break ;
default :
throw new NotSupportedException ( "Not supported compiler." ) ;
}
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
string [ ] PossibleRegPaths = new string [ ] {
@"Wow6432Node\Microsoft\VisualStudio" , // Non-express VS2013 on 64-bit machine.
@"Microsoft\VisualStudio" , // Non-express VS2013 on 32-bit machine.
@"Wow6432Node\Microsoft\WDExpress" , // Express VS2013 on 64-bit machine.
@"Microsoft\WDExpress" // Express VS2013 on 32-bit machine.
} ;
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
string VSPath = null ;
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
foreach ( var PossibleRegPath in PossibleRegPaths )
{
VSPath = ( string ) Registry . GetValue ( string . Format ( @"HKEY_LOCAL_MACHINE\SOFTWARE\{0}\{1}.0" , PossibleRegPath , VSVersion ) , "InstallDir" , null ) ;
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
if ( VSPath ! = null )
{
break ;
}
}
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
if ( VSPath = = null )
{
return null ;
}
2014-04-23 20:18:55 -04:00
2014-07-18 14:21:02 -04:00
return new DirectoryInfo ( Path . Combine ( VSPath , ".." , "Tools" ) ) . FullName ;
}
2014-04-23 20:18:55 -04:00
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Register the platform with the UEBuildPlatform class
* /
protected override void RegisterBuildPlatformInternal ( )
{
// Register this build platform for both Win64 and Win32
Log . TraceVerbose ( " Registering for {0}" , UnrealTargetPlatform . Win64 . ToString ( ) ) ;
UEBuildPlatform . RegisterBuildPlatform ( UnrealTargetPlatform . Win64 , this ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Win64 , UnrealPlatformGroup . Windows ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Win64 , UnrealPlatformGroup . Microsoft ) ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
Log . TraceVerbose ( " Registering for {0}" , UnrealTargetPlatform . Win32 . ToString ( ) ) ;
UEBuildPlatform . RegisterBuildPlatform ( UnrealTargetPlatform . Win32 , this ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Win32 , UnrealPlatformGroup . Windows ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Win32 , UnrealPlatformGroup . Microsoft ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Retrieve the CPPTargetPlatform for the given UnrealTargetPlatform
*
* @param InUnrealTargetPlatform The UnrealTargetPlatform being build
*
* @return CPPTargetPlatform The CPPTargetPlatform to compile for
* /
public override CPPTargetPlatform GetCPPTargetPlatform ( UnrealTargetPlatform InUnrealTargetPlatform )
{
switch ( InUnrealTargetPlatform )
{
case UnrealTargetPlatform . Win32 :
return CPPTargetPlatform . Win32 ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
case UnrealTargetPlatform . Win64 :
return CPPTargetPlatform . Win64 ;
}
throw new BuildException ( "WindowsPlatform::GetCPPTargetPlatform: Invalid request for {0}" , InUnrealTargetPlatform . ToString ( ) ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Get the extension to use for the given binary type
*
* @param InBinaryType The binrary type being built
*
* @return string The binary extenstion ( ie ' exe ' or ' dll ' )
* /
public override string GetBinaryExtension ( UEBuildBinaryType InBinaryType )
{
switch ( InBinaryType )
{
case UEBuildBinaryType . DynamicLinkLibrary :
return ".dll" ;
case UEBuildBinaryType . Executable :
return ".exe" ;
case UEBuildBinaryType . StaticLibrary :
return ".lib" ;
case UEBuildBinaryType . Object :
2014-12-04 05:35:51 -05:00
if ( ! BuildConfiguration . bRunUnrealCodeAnalyzer )
{
return ".obj" ;
}
else
{
return @".includes" ;
}
2014-07-18 14:21:02 -04:00
case UEBuildBinaryType . PrecompiledHeader :
return ".pch" ;
}
return base . GetBinaryExtension ( InBinaryType ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/// <summary>
/// When using a Visual Studio compiler, returns the version name as a string
/// </summary>
/// <returns>The Visual Studio compiler version name (e.g. "2012")</returns>
public static string GetVisualStudioCompilerVersionName ( )
{
switch ( Compiler )
{
case WindowsCompiler . VisualStudio2012 :
return "2012" ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
case WindowsCompiler . VisualStudio2013 :
return "2013" ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
default :
throw new BuildException ( "Unexpected WindowsCompiler version for GetVisualStudioCompilerVersionName(). Either not using a Visual Studio compiler or switch block needs to be updated" ) ;
}
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Get the extension to use for debug info for the given binary type
*
* @param InBinaryType The binary type being built
*
* @return string The debug info extension ( i . e . ' pdb ' )
* /
public override string GetDebugInfoExtension ( UEBuildBinaryType InBinaryType )
{
2014-03-14 14:13:41 -04:00
switch ( InBinaryType )
{
case UEBuildBinaryType . DynamicLinkLibrary :
2014-07-18 14:21:02 -04:00
case UEBuildBinaryType . Executable :
2014-03-14 14:13:41 -04:00
return ".pdb" ;
}
return "" ;
}
2014-07-18 14:21:02 -04:00
/ * *
* Whether incremental linking should be used
*
* @param InPlatform The CPPTargetPlatform being built
* @param InConfiguration The CPPTargetConfiguration being built
*
* @return bool true if incremental linking should be used , false if not
* /
public override bool ShouldUseIncrementalLinking ( CPPTargetPlatform Platform , CPPTargetConfiguration Configuration )
{
return ( Configuration = = CPPTargetConfiguration . Debug ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Whether PDB files should be used
*
* @param InPlatform The CPPTargetPlatform being built
* @param InConfiguration The CPPTargetConfiguration being built
* @param bInCreateDebugInfo true if debug info is getting create , false if not
*
* @return bool true if PDB files should be used , false if not
* /
public override bool ShouldUsePDBFiles ( CPPTargetPlatform Platform , CPPTargetConfiguration Configuration , bool bCreateDebugInfo )
{
// Only supported on PC.
if ( bCreateDebugInfo & & ShouldUseIncrementalLinking ( Platform , Configuration ) )
{
return true ;
}
return false ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Whether the editor should be built for this platform or not
*
* @param InPlatform The UnrealTargetPlatform being built
* @param InConfiguration The UnrealTargetConfiguration being built
* @return bool true if the editor should be built , false if not
* /
public override bool ShouldNotBuildEditor ( UnrealTargetPlatform InPlatform , UnrealTargetConfiguration InConfiguration )
{
return false ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
public override bool BuildRequiresCookedData ( UnrealTargetPlatform InPlatform , UnrealTargetConfiguration InConfiguration )
{
return false ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
public override void ResetBuildConfiguration ( UnrealTargetPlatform InPlatform , UnrealTargetConfiguration InConfiguration )
{
2015-01-28 08:26:51 -05:00
UEBuildConfiguration . bCompileICU = true ;
// Should we enable Windows XP support
{
// If it wasnt set as an XML flag, check if it is requested from the commandline.
if ( ! SupportWindowsXPIfAvailable )
{
string [ ] CmdLine = Environment . GetCommandLineArgs ( ) ;
SupportWindowsXPIfAvailable = CmdLine . Contains ( "-winxp" , StringComparer . InvariantCultureIgnoreCase ) ;
// ...check if it was supported from a config.
if ( ! SupportWindowsXPIfAvailable )
{
ConfigCacheIni Ini = new ConfigCacheIni ( UnrealTargetPlatform . Win64 , "Engine" , UnrealBuildTool . GetUProjectPath ( ) ) ;
string MinimumOS ;
if ( Ini . GetString ( "/Script/WindowsTargetPlatform.WindowsTargetSettings" , "MinimumOSVersion" , out MinimumOS ) )
{
if ( string . IsNullOrEmpty ( MinimumOS ) = = false )
{
SupportWindowsXPIfAvailable = MinimumOS = = "MSOS_XP" ;
}
}
}
}
// Win32 XP is only supported at this time.
SupportWindowsXP = SupportWindowsXPIfAvailable & & ( GetCPPTargetPlatform ( InPlatform ) = = CPPTargetPlatform . Win32 ) ;
}
2014-07-18 14:21:02 -04:00
}
2014-03-14 14:13:41 -04:00
public override void ValidateBuildConfiguration ( CPPTargetConfiguration Configuration , CPPTargetPlatform Platform , bool bCreateDebugInfo )
{
2014-07-18 14:21:02 -04:00
if ( WindowsPlatform . bCompileWithClang )
{
2015-03-27 16:44:10 -04:00
// @todo clang: Shared PCHs don't work on clang yet because the PCH will have definitions assigned to different values
// than the consuming translation unit. Unlike the warning in MSVC, this is a compile in Clang error which cannot be suppressed
2014-07-18 14:21:02 -04:00
BuildConfiguration . bUseSharedPCHs = false ;
2015-03-27 16:44:10 -04:00
// @todo clang: PCH files aren't supported by "clang-cl" yet (no /Yc support, and "-x c++-header" cannot be specified)
if ( WindowsPlatform . bUseVCCompilerArgs )
{
BuildConfiguration . bUsePCHFiles = false ;
}
2014-07-18 14:21:02 -04:00
}
2014-03-14 14:13:41 -04:00
}
2014-07-18 14:21:02 -04:00
/ * *
2014-03-14 14:13:41 -04:00
* Validate the UEBuildConfiguration for this platform
* This is called BEFORE calling UEBuildConfiguration to allow setting
* various fields used in that function such as CompileLeanAndMean . . .
* /
public override void ValidateUEBuildConfiguration ( )
{
2014-08-18 11:29:11 -04:00
UEBuildConfiguration . bCompileICU = true ;
2014-07-18 14:21:02 -04:00
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
public override void ModifyNewlyLoadedModule ( UEBuildModule InModule , TargetInfo Target )
{
if ( ( Target . Platform = = UnrealTargetPlatform . Win32 ) | | ( Target . Platform = = UnrealTargetPlatform . Win64 ) )
{
2014-03-14 14:13:41 -04:00
bool bBuildShaderFormats = UEBuildConfiguration . bForceBuildShaderFormats ;
if ( ! UEBuildConfiguration . bBuildRequiresCookedData )
{
if ( InModule . ToString ( ) = = "TargetPlatform" )
{
bBuildShaderFormats = true ;
}
}
2014-07-18 14:21:02 -04:00
// allow standalone tools to use target platform modules, without needing Engine
if ( UEBuildConfiguration . bForceBuildTargetPlatforms )
{
InModule . AddDynamicallyLoadedModule ( "WindowsTargetPlatform" ) ;
InModule . AddDynamicallyLoadedModule ( "WindowsNoEditorTargetPlatform" ) ;
InModule . AddDynamicallyLoadedModule ( "WindowsServerTargetPlatform" ) ;
InModule . AddDynamicallyLoadedModule ( "WindowsClientTargetPlatform" ) ;
2015-02-17 09:57:44 -05:00
InModule . AddDynamicallyLoadedModule ( "DesktopTargetPlatform" ) ;
2014-07-18 14:21:02 -04:00
}
2014-03-14 14:13:41 -04:00
if ( bBuildShaderFormats )
{
InModule . AddDynamicallyLoadedModule ( "ShaderFormatD3D" ) ;
InModule . AddDynamicallyLoadedModule ( "ShaderFormatOpenGL" ) ;
}
2014-07-18 14:21:02 -04:00
if ( InModule . ToString ( ) = = "D3D11RHI" )
{
// To enable platform specific D3D11 RHI Types
InModule . AddPrivateIncludePath ( "Runtime/Windows/D3D11RHI/Private/Windows" ) ;
}
}
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Setup the target environment for building
*
* @param InBuildTarget The target being built
* /
public override void SetUpEnvironment ( UEBuildTarget InBuildTarget )
{
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "WIN32=1" ) ;
2014-04-28 11:19:24 -04:00
2015-02-03 11:57:21 -05:00
// Win32 XP is only supported at this time.
SupportWindowsXP = SupportWindowsXPIfAvailable & & ( GetCPPTargetPlatform ( InBuildTarget . Platform ) = = CPPTargetPlatform . Win32 ) ;
2015-01-28 08:26:51 -05:00
if ( IsWindowsXPSupported ( ) )
2014-07-18 14:21:02 -04:00
{
// Windows XP SP3 or higher required
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "_WIN32_WINNT=0x0502" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "WINVER=0x0502" ) ;
}
else
{
// Windows Vista or higher required
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "_WIN32_WINNT=0x0600" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "WINVER=0x0600" ) ;
}
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "PLATFORM_WINDOWS=1" ) ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
String MorpheusShaderPath = Path . Combine ( BuildConfiguration . RelativeEnginePath , "Shaders/PS4/PostProcessHMDMorpheus.usf" ) ;
if ( File . Exists ( MorpheusShaderPath ) )
{
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "HAS_MORPHEUS=1" ) ;
2015-04-22 16:41:54 -04:00
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "MORPHEUS_120HZ=0" ) ;
2015-02-16 14:26:39 -05:00
//on PS4 the SDK now handles distortion correction. On PC we will still have to handle it manually,
//but we require SDK changes before we can get the required data. For the moment, no platform does in-engine morpheus distortion
2015-04-08 17:24:01 -04:00
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "MORPHEUS_ENGINE_DISTORTION=1" ) ;
2014-07-18 14:21:02 -04:00
}
2014-04-23 17:31:09 -04:00
2014-07-18 14:21:02 -04:00
if ( InBuildTarget . Rules ! = null )
{
// 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.
2014-09-23 13:55:06 -04:00
bool bUseDebugCRT = InBuildTarget . Configuration = = UnrealTargetConfiguration . Debug & & BuildConfiguration . bDebugBuildsActuallyUseDebugCRT ;
if ( ! InBuildTarget . Rules . bUseStaticCRT | | bUseDebugCRT )
{
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBCMT" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBCPMT" ) ;
}
if ( ! InBuildTarget . Rules . bUseStaticCRT | | ! bUseDebugCRT )
{
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBCMTD" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBCPMTD" ) ;
}
if ( InBuildTarget . Rules . bUseStaticCRT | | bUseDebugCRT )
{
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "MSVCRT" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "MSVCPRT" ) ;
}
if ( InBuildTarget . Rules . bUseStaticCRT | | ! bUseDebugCRT )
{
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "MSVCRTD" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "MSVCPRTD" ) ;
}
2014-07-18 14:21:02 -04:00
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBC" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBCP" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBCD" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "LIBCPD" ) ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
//@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 Rocket games
// 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 ( InBuildTarget . ShouldCompileMonolithic ( ) & & ( InBuildTarget . Rules ! = null ) & &
2014-08-29 15:46:20 -04:00
( TargetRules . IsGameType ( InBuildTarget . TargetType ) ) & & ( TargetRules . IsEditorType ( InBuildTarget . TargetType ) = = false ) )
2014-07-18 14:21:02 -04:00
{
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "atl" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "atls" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "atlsd" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "atlsn" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . ExcludedLibraries . Add ( "atlsnd" ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// Add the library used for the delayed loading of DLLs.
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "delayimp.lib" ) ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
//@todo - remove once FB implementation uses Http module
if ( UEBuildConfiguration . bCompileAgainstEngine )
{
// link against wininet (used by FBX and Facebook)
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "wininet.lib" ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// Compile and link with Win32 API libraries.
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "rpcrt4.lib" ) ;
//InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("wsock32.lib");
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "ws2_32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "dbghelp.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "comctl32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "Winmm.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "kernel32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "user32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "gdi32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "winspool.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "comdlg32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "advapi32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "shell32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "ole32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "oleaut32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "uuid.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "odbc32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "odbccp32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "netapi32.lib" ) ;
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "iphlpapi.lib" ) ;
2014-03-14 14:13:41 -04:00
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "setupapi.lib" ) ; // Required for access monitor device enumeration
2015-01-28 08:26:51 -05:00
// Windows Vista/7 Desktop Windows Manager API for Slate Windows Compliance
if ( IsWindowsXPSupported ( ) = = false ) // Windows XP does not support DWM
2014-07-18 14:21:02 -04:00
{
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "dwmapi.lib" ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// IME
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalLibraries . Add ( "imm32.lib" ) ;
2014-04-02 18:09:23 -04:00
2014-07-18 14:21:02 -04:00
// Setup assembly path for .NET modules. This will only be used when CLR is enabled. (CPlusPlusCLR module types)
InBuildTarget . GlobalCompileEnvironment . Config . SystemDotNetAssemblyPaths . Add (
Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFilesX86 ) +
"/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0" ) ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// Setup default assemblies for .NET modules. These will only be used when CLR is enabled. (CPlusPlusCLR module types)
InBuildTarget . GlobalCompileEnvironment . Config . FrameworkAssemblyDependencies . Add ( "System.dll" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . FrameworkAssemblyDependencies . Add ( "System.Data.dll" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . FrameworkAssemblyDependencies . Add ( "System.Drawing.dll" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . FrameworkAssemblyDependencies . Add ( "System.Xml.dll" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . FrameworkAssemblyDependencies . Add ( "System.Management.dll" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . FrameworkAssemblyDependencies . Add ( "System.Windows.Forms.dll" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . FrameworkAssemblyDependencies . Add ( "WindowsBase.dll" ) ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// Disable Simplygon support if compiling against the NULL RHI.
if ( InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Contains ( "USE_NULL_RHI=1" ) )
{
UEBuildConfiguration . bCompileSimplygon = false ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// 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.
if ( InBuildTarget . Platform = = UnrealTargetPlatform . Win64 )
{
InBuildTarget . GlobalLinkEnvironment . Config . AdditionalArguments + = " /ignore:4078" ;
}
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Setup the configuration environment for building
*
* @param InBuildTarget The target being built
* /
public override void SetUpConfigurationEnvironment ( UEBuildTarget InBuildTarget )
{
// Determine the C++ compile/link configuration based on the Unreal configuration.
CPPTargetConfiguration CompileConfiguration ;
//@todo SAS: Add a true Debug mode!
UnrealTargetConfiguration CheckConfig = InBuildTarget . Configuration ;
switch ( CheckConfig )
{
default :
case UnrealTargetConfiguration . Debug :
CompileConfiguration = CPPTargetConfiguration . Debug ;
if ( BuildConfiguration . bDebugBuildsActuallyUseDebugCRT )
{
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "_DEBUG=1" ) ; // the engine doesn't use this, but lots of 3rd party stuff does
}
else
{
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "NDEBUG=1" ) ; // the engine doesn't use this, but lots of 3rd party stuff does
}
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "UE_BUILD_DEBUG=1" ) ;
break ;
case UnrealTargetConfiguration . DebugGame :
// Default to Development; can be overriden by individual modules.
case UnrealTargetConfiguration . Development :
CompileConfiguration = CPPTargetConfiguration . Development ;
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "NDEBUG=1" ) ; // the engine doesn't use this, but lots of 3rd party stuff does
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "UE_BUILD_DEVELOPMENT=1" ) ;
break ;
case UnrealTargetConfiguration . Shipping :
CompileConfiguration = CPPTargetConfiguration . Shipping ;
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "NDEBUG=1" ) ; // the engine doesn't use this, but lots of 3rd party stuff does
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "UE_BUILD_SHIPPING=1" ) ;
break ;
case UnrealTargetConfiguration . Test :
CompileConfiguration = CPPTargetConfiguration . Shipping ;
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "NDEBUG=1" ) ; // the engine doesn't use this, but lots of 3rd party stuff does
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "UE_BUILD_TEST=1" ) ;
break ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// Set up the global C++ compilation and link environment.
InBuildTarget . GlobalCompileEnvironment . Config . Target . Configuration = CompileConfiguration ;
InBuildTarget . GlobalLinkEnvironment . Config . Target . Configuration = CompileConfiguration ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// Create debug info based on the heuristics specified by the user.
InBuildTarget . GlobalCompileEnvironment . Config . bCreateDebugInfo =
! BuildConfiguration . bDisableDebugInfo & & ShouldCreateDebugInfo ( InBuildTarget . Platform , CheckConfig ) ;
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
// 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.
InBuildTarget . GlobalLinkEnvironment . Config . bCreateDebugInfo = true ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Whether this platform should create debug information or not
*
* @param InPlatform The UnrealTargetPlatform being built
* @param InConfiguration The UnrealTargetConfiguration being built
*
* @return bool true if debug info should be generated , false if not
* /
public override bool ShouldCreateDebugInfo ( UnrealTargetPlatform Platform , UnrealTargetConfiguration Configuration )
{
switch ( Configuration )
{
case UnrealTargetConfiguration . Development :
case UnrealTargetConfiguration . Shipping :
case UnrealTargetConfiguration . Test :
return ! BuildConfiguration . bOmitPCDebugInfoInDevelopment ;
case UnrealTargetConfiguration . DebugGame :
case UnrealTargetConfiguration . Debug :
default :
return true ;
} ;
}
2014-03-14 14:13:41 -04:00
2014-07-18 14:21:02 -04:00
/ * *
* Return whether this platform has uniquely named binaries across multiple games
* /
public override bool HasUniqueBinaries ( )
{
// Windows applications have many shared binaries between games
return false ;
}
}
2014-03-14 14:13:41 -04:00
}