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
{
2015-05-05 15:32:10 -04:00
/// <summary>
/// Available compiler toolchains on Windows platform
/// </summary>
public enum WindowsCompiler
{
/// Visual Studio 2012 (Visual C++ 11.0). No longer supported for building on Windows, but required for other platform toolchains.
VisualStudio2012 ,
2014-03-14 14:13:41 -04:00
2015-05-05 15:32:10 -04:00
/// Visual Studio 2013 (Visual C++ 12.0)
VisualStudio2013 ,
/// Visual Studio 2015 (Visual C++ 14.0)
VisualStudio2015 ,
}
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
2015-05-05 15:32:10 -04:00
// First, default based on whether there is a command line override...
if ( UnrealBuildTool . CommandLineContains ( "-2012" ) )
{
2015-05-07 15:47:59 -04:00
// We don't support compiling with VS 2012 on Windows platform, but you can still generate project files that are 2012-compatible. That's handled elsewhere
2015-05-05 15:32:10 -04:00
}
2015-05-07 15:47:59 -04:00
if ( UnrealBuildTool . CommandLineContains ( "-2013" ) )
2015-05-05 15:32:10 -04:00
{
CachedCompiler = WindowsCompiler . VisualStudio2013 ;
}
else if ( UnrealBuildTool . CommandLineContains ( "-2015" ) )
{
CachedCompiler = WindowsCompiler . VisualStudio2015 ;
}
2014-06-26 06:00:21 -04:00
2015-05-05 15:32:10 -04:00
// Second, default based on what's installed, from newest to oldest
2015-05-12 12:00:23 -04:00
// @todo UWP: Currently we default to VS 2013, even if VS 2015 is installed, until the engine is fully updated to
2015-05-05 15:32:10 -04:00
// support compiling with VS 2015. You can override this with the "-2015" command-line switch.
2015-05-05 15:57:44 -04:00
// else if (!String.IsNullOrEmpty(WindowsPlatform.GetVSComnToolsPath(WindowsCompiler.VisualStudio2015)))
// {
// CachedCompiler = WindowsCompiler.VisualStudio2015;
// }
2015-05-05 15:32:10 -04:00
else if ( ! String . IsNullOrEmpty ( WindowsPlatform . GetVSComnToolsPath ( WindowsCompiler . VisualStudio2013 ) ) )
{
CachedCompiler = WindowsCompiler . VisualStudio2013 ;
}
else
{
// Finally assume 2013 is installed to defer errors somewhere else like VCToolChain
CachedCompiler = WindowsCompiler . VisualStudio2013 ;
}
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
Miscellaneous fixes for Clang on windows
These changes allow UE4 to compile and run (in Debug) on Clang 3.7 alpha (r231657 only!)
- Disabled editor source file discovery (crashes with Clang currently)
- Disabled FThreadIdleStats in UnrealHeaderTool with Clang on Windows (causes link errors due to inlining bugs with Clang and DLL imports)
- Use MSVC linker by default, even when compiling with Clang (can be tweaked with bAllowClangLinker)
- Enabled shadow variable warnings on Windows with Clang
- Limited max size of reflection code source files (Clang on Windows crashes with huge source files)
- Fixed UE4 deprecation warnings not showing up when using Clang on Windows
- Make sure initialization list order only triggers a warning on Clang for Windows
Other changes:
- Fixed issues with pushed pragmas not getting popped (PRAGMA_ENABLE_DEPRECATION_WARNINGS)
- Removed EMIT_DEPRECATED_WARNING_MESSAGE, wasn't used
- Fixed various third party library includes not being treated as system headers (prevents compiler warnings)
To test Clang on Windows (beta!!):
- Get latest UE4 main branch (4.9)
- Install LLVM+Clang for Windows version r231657. It's a quick install, you don't need to compile anything yourself.
- Open UEBuildWindows.cs, and change bCompileWithClang to true. Be careful not to check that in. We'll probably make this config-driven later, after the Clang toolchain gets more mature.
- Switch to Debug Editor configuration. (See below for more info.)
- Rebuild the game or engine
Notes:
- You must use Clang r231657 (3.7.0 alpha). There are no other releases that I've found that are able to compile UE4 successfully. Most of the newer releases crash during compiling, and older releases aren't able to digest Windows header files well enough.
- Compiling in Development currently will not work due to bugs with Clangs handling of inlining and DLL exports. Monolithic builds should work, though.
- Occasionally you may see runtime crashes (stack overflows or access violations) when running UE4 compiled with Clang on Windows. These may very well be bugs in Clang (remember, we're using an alpha release of Clang 3.7.0.) Unfortunately without better debugger support, it can be difficult to workaround these
- When debugging, you will only have functions and line numbers, no variables or parameters. Clang only has preliminary support for Microsoft's PDB format currently.
XGE is fully supported with Clang on Windows. Best case rebuild times I've seen are 3.5 minutes in Debug.
- Shared PCHs aren't supported yet (similar to on Mac and Linux), so iterative compile times may be slower compared to Visual C++. However the Clang compiler is actually quite fast for rebuilds, probably because of missing debug info though.
- There may be some compiler warnings that are different between Mac/Linux and Windows. We haven't done a line-by-line comparison yet.
- Build products and executables for Clang and VC++ overlap on disk. So you have to rebuild to switch back and forth. Sorry.
- Clang on Windows has a few bugs that we've had to work around. You might see some strange things from time to time. Every new release of Clang has different behavior on Windows.
- We still use the VC++ Linker, even when compiling using Clang. The new Clang linker (lld.exe) can be enabled with bAllowClangLinker but it will crash when linking some modules. It also doesn't produce usable debug symbols by Visual Studio (yet).
#codereview mikolaj.sieluzycki
[CL 2532260 by Mike Fricker in Main branch]
2015-04-30 14:24:21 -04:00
public static readonly bool bAllowClangLinker = bCompileWithClang & & false ;
2014-03-14 14:13:41 -04:00
2015-05-05 15:32:10 -04:00
/// Whether to compile against the Windows 10 SDK, instead of the Windows 8.1 SDK. This requires the Visual Studio 2015
/// compiler or later, and the Windows 10 SDK must be installed. The application will require at least Windows 8.x to run.
2015-05-12 12:00:23 -04:00
// @todo UWP: Expose this to be enabled more easily for building Windows 10 desktop apps
2015-05-05 15:32:10 -04:00
public static readonly bool bUseWindowsSDK10 = false ;
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
2015-05-14 12:40:00 -04:00
public static bool SupportWindowsXP ;
2015-01-28 08:26:51 -05:00
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
{
2015-05-05 15:32:10 -04:00
// Interrogate the Win32 registry
string DTEKey = null ;
switch ( Compiler )
{
case WindowsCompiler . VisualStudio2015 :
DTEKey = "VisualStudio.DTE.14.0" ;
break ;
case WindowsCompiler . VisualStudio2013 :
DTEKey = "VisualStudio.DTE.12.0" ;
break ;
case WindowsCompiler . VisualStudio2012 :
DTEKey = "VisualStudio.DTE.11.0" ;
break ;
}
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
2015-05-05 15:32:10 -04:00
switch ( Compiler )
{
case WindowsCompiler . VisualStudio2012 :
VSVersion = 11 ;
break ;
case WindowsCompiler . VisualStudio2013 :
VSVersion = 12 ;
break ;
case WindowsCompiler . VisualStudio2015 :
VSVersion = 14 ;
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
2015-07-03 05:23:01 -04:00
/ * *
* If this platform can be compiled with SN - DBS
* /
public override bool CanUseSNDBS ( )
{
// Check that SN-DBS is available
string SCERootPath = Environment . GetEnvironmentVariable ( "SCE_ROOT_DIR" ) ;
2015-07-03 07:00:18 -04:00
if ( ! String . IsNullOrEmpty ( SCERootPath ) )
{
string SNDBSPath = Path . Combine ( SCERootPath , "common" , "sn-dbs" , "bin" , "dbsbuild.exe" ) ;
bool bIsSNDBSAvailable = File . Exists ( SNDBSPath ) ;
return bIsSNDBSAvailable ;
}
else
{
return false ;
}
2015-07-03 05:23:01 -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>
2015-05-05 15:32:10 -04:00
public static string GetVisualStudioCompilerVersionName ( )
{
switch ( Compiler )
{
case WindowsCompiler . VisualStudio2012 :
return "2012" ;
2014-03-14 14:13:41 -04:00
2015-05-05 15:32:10 -04:00
case WindowsCompiler . VisualStudio2013 :
return "2013" ;
2014-03-14 14:13:41 -04:00
2015-05-05 15:32:10 -04:00
case WindowsCompiler . VisualStudio2015 :
return "2015" ;
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
2015-06-03 08:40:17 -04:00
public override bool HasDefaultBuildConfig ( UnrealTargetPlatform Platform , string ProjectPath )
{
if ( Platform = = UnrealTargetPlatform . Win32 )
{
string [ ] StringKeys = new string [ ] {
"MinimumOSVersion"
} ;
// look up OS specific settings
if ( ! DoProjectSettingsMatchDefault ( Platform , ProjectPath , "/Script/WindowsTargetPlatform.WindowsTargetSettings" ,
null , null , StringKeys ) )
{
return false ;
}
}
// check the base settings
return base . HasDefaultBuildConfig ( Platform , ProjectPath ) ;
}
2015-05-14 12:40:00 -04:00
private void SetupXPSupportFromConfiguration ( )
{
string [ ] CmdLine = Environment . GetCommandLineArgs ( ) ;
bool SupportWindowsXPIfAvailable = false ;
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" ;
}
}
}
SupportWindowsXP = SupportWindowsXPIfAvailable ;
}
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 ;
2015-05-14 12:40:00 -04:00
if ( InPlatform = = UnrealTargetPlatform . Win32 )
2015-01-28 08:26:51 -05:00
{
2015-05-14 12:40:00 -04:00
SetupXPSupportFromConfiguration ( ) ;
2015-01-28 08:26:51 -05:00
}
2015-05-14 12:40:00 -04:00
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-06-16 11:09:27 -04:00
InModule . AddDynamicallyLoadedModule ( "AllDesktopTargetPlatform" ) ;
2014-07-18 14:21:02 -04:00
}
2014-03-14 14:13:41 -04:00
if ( bBuildShaderFormats )
{
InModule . AddDynamicallyLoadedModule ( "ShaderFormatD3D" ) ;
InModule . AddDynamicallyLoadedModule ( "ShaderFormatOpenGL" ) ;
2015-06-15 18:02:36 -04:00
//#todo-rco: Remove when public
{
string VulkanSDKPath = Environment . GetEnvironmentVariable ( "VulkanSDK" ) ;
if ( ! String . IsNullOrEmpty ( VulkanSDKPath ) )
{
InModule . AddDynamicallyLoadedModule ( "VulkanShaderFormat" ) ;
}
}
}
2014-03-14 14:13:41 -04:00
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" ) ;
}
2015-07-14 10:56:01 -04:00
if ( InModule . ToString ( ) = = "D3D12RHI" )
{
// To enable platform specific D3D12 RHI Types
InModule . AddPrivateIncludePath ( "Runtime/Windows/D3D12RHI/Private/Windows" ) ;
}
}
2014-07-18 14:21:02 -04:00
}
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-05-14 12:40:00 -04:00
// Should we enable Windows XP support
if ( ( InBuildTarget . TargetType = = TargetRules . TargetType . Program ) & & ( GetCPPTargetPlatform ( InBuildTarget . Platform ) = = CPPTargetPlatform . Win32 ) )
{
// Check if the target has requested XP support.
if ( String . Equals ( InBuildTarget . Rules . PreferredSubPlatform , "WindowsXP" , StringComparison . InvariantCultureIgnoreCase ) )
{
SupportWindowsXP = true ;
}
}
2015-05-05 15:32:10 -04:00
if ( WindowsPlatform . bUseWindowsSDK10 & & WindowsPlatform . Compiler = = WindowsCompiler . VisualStudio2015 )
{
if ( SupportWindowsXP )
{
throw new NotSupportedException ( "Windows XP support is not possible when targeting the Windows 10 SDK" ) ;
}
// Windows 8 or higher required
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "_WIN32_WINNT=0x0602" ) ;
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "WINVER=0x0602" ) ;
}
else
{
if ( SupportWindowsXP )
{
// 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" ) ;
2015-08-11 17:29:08 -04:00
//@todo: VS2015 currently does not have support for Morpheus
if ( File . Exists ( MorpheusShaderPath ) & & WindowsPlatform . Compiler ! = WindowsCompiler . VisualStudio2015 )
2014-07-18 14:21:02 -04:00
{
2015-06-15 18:12:08 -04:00
InBuildTarget . GlobalCompileEnvironment . Config . Definitions . Add ( "HAS_MORPHEUS=1" ) ;
2015-02-16 14:26:39 -05:00
2015-06-15 18:12:08 -04:00
//on PS4 the SDK now handles distortion correction. On PC we will still have to handle it manually,
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 :
2015-08-05 15:54:57 -04:00
// Default to Development; can be overridden by individual modules.
2014-07-18 14:21:02 -04:00
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
}