Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/ToolChain/UEToolChain.cs
Mike Fricker 80f6dc9362 UnrealBuildTool: Experimental fast C++ include dependency scanning
- Adds experimental super-fast C++ outdated file checking
- This feature is turned off for now as we continue to test and improve it
      - You can try it out by enabling "bUseExperimentalFastDependencyScan" option in your BuildConfiguration.xml
- Here is the basic idea:
     - We no longer exhaustively scan all includes and build up a big graph every invocation
     - Instead, source files whose build products are missing have their includes scanned asynchronously while being compiled
     - The flat list of dependent includes for every outdated C++ is saved into a new cache file ("FlatCPPIncludes.bin")
     - On the next run, we quickly load that up and "just know" which files to check timestamps on to determine what is out of date
- Lots of "@todo fastubt" comments were added to UnrealBuildTool for potential performance optimizations and further improvements on this feature.

UnrealBuildTool: Determination of which modules have UObjects is now faster
- We now cache which modules have UObjects and load those for the next session

UnrealBuildTool: Module "shared" precompiled header determination is now much faster
- We no longer scan all C++ includes for a module to figure out which "shared" PCH to use
- Instead, we use the module dependencies specified in the module's *.Build.cs file
- For example, if your module depends on "Engine" and "UnrealEd", we choose "UnrealEd"'s shared PCH

Other UBT optimizations:
- Reduced calls to string formatting functions when setting up API definitions for all modules
- Added new performance diagnostics when bPrintPerformanceInfo is enabled in BuildConfiguration.xml
- We no longer check for "external" headers when scanning includes (this code didn't work at all)
- Optimized CleanDirectorySeparators() utility function to avoid string copies

Fixed UnrealBuildTool not saving DependencyCache under a platform-named folder

[CL 2238266 by Mike Fricker in Main branch]
2014-07-31 09:34:11 -04:00

163 lines
5.5 KiB
C#

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.IO;
using Microsoft.Win32;
namespace UnrealBuildTool
{
public interface IUEToolChain
{
void RegisterToolChain();
CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName);
CPPOutput CompileRCFiles(UEBuildTarget Target, CPPEnvironment Environment, List<FileItem> RCFiles);
FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly);
void CompileCSharpProject(CSharpEnvironment CompileEnvironment, string ProjectFileName, string DestinationFile);
/** Converts the passed in path from UBT host to compiler native format. */
String ConvertPath(String OriginalPath);
/// <summary>
/// Called immediately after UnrealHeaderTool is executed to generated code for all UObjects modules. Only is called if UnrealHeaderTool was actually run in this session.
/// </summary>
/// <param name="UObjectModules">List of UObject modules we generated code for.</param>
void PostCodeGeneration(UEBuildTarget Target, UHTManifest Manifest);
void PreBuildSync();
void PostBuildSync(UEBuildTarget Target);
ICollection<FileItem> PostBuild(FileItem Executable, LinkEnvironment ExecutableLinkEnvironment);
void SetUpGlobalEnvironment();
void AddFilesToManifest(ref FileManifest manifest, UEBuildBinary Binary );
}
public abstract class UEToolChain : IUEToolChain
{
static Dictionary<CPPTargetPlatform, IUEToolChain> CPPToolChainDictionary = new Dictionary<CPPTargetPlatform, IUEToolChain>();
public static void RegisterPlatformToolChain(CPPTargetPlatform InPlatform, IUEToolChain InToolChain)
{
if (CPPToolChainDictionary.ContainsKey(InPlatform) == true)
{
Log.TraceInformation("RegisterPlatformToolChain Warning: Registering tool chain {0} for {1} when it is already set to {2}",
InToolChain.ToString(), InPlatform.ToString(), CPPToolChainDictionary[InPlatform].ToString());
CPPToolChainDictionary[InPlatform] = InToolChain;
}
else
{
CPPToolChainDictionary.Add(InPlatform, InToolChain);
}
}
public static void UnregisterPlatformToolChain(CPPTargetPlatform InPlatform)
{
CPPToolChainDictionary.Remove(InPlatform);
}
public static IUEToolChain GetPlatformToolChain(CPPTargetPlatform InPlatform)
{
if (CPPToolChainDictionary.ContainsKey(InPlatform) == true)
{
return CPPToolChainDictionary[InPlatform];
}
throw new BuildException("GetPlatformToolChain: No tool chain found for {0}", InPlatform.ToString());
}
public abstract void RegisterToolChain();
public abstract CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName);
public virtual CPPOutput CompileRCFiles(UEBuildTarget Target, CPPEnvironment Environment, List<FileItem> RCFiles)
{
CPPOutput Result = new CPPOutput();
return Result;
}
public abstract FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly);
public virtual void CompileCSharpProject(CSharpEnvironment CompileEnvironment, string ProjectFileName, string DestinationFile)
{
}
/// <summary>
/// Get the name of the response file for the current linker environment and output file
/// </summary>
/// <param name="LinkEnvironment"></param>
/// <param name="OutputFile"></param>
/// <returns></returns>
public static string GetResponseFileName( LinkEnvironment LinkEnvironment, FileItem OutputFile )
{
// Construct a relative path for the intermediate response file
string ResponseFileName = Path.Combine( LinkEnvironment.Config.IntermediateDirectory, Path.GetFileName( OutputFile.AbsolutePath ) + ".response" );
if (UnrealBuildTool.HasUProjectFile())
{
// If this is the uproject being built, redirect the intermediate
if (Utils.IsFileUnderDirectory( OutputFile.AbsolutePath, UnrealBuildTool.GetUProjectPath() ))
{
ResponseFileName = Path.Combine(
UnrealBuildTool.GetUProjectPath(),
BuildConfiguration.PlatformIntermediateFolder,
Path.GetFileNameWithoutExtension(UnrealBuildTool.GetUProjectFile()),
LinkEnvironment.Config.Target.Configuration.ToString(),
Path.GetFileName(OutputFile.AbsolutePath) + ".response");
}
}
// Convert the relative path to an absolute path
ResponseFileName = Path.GetFullPath( ResponseFileName );
return ResponseFileName;
}
/** Converts the passed in path from UBT host to compiler native format. */
public virtual String ConvertPath(String OriginalPath)
{
return OriginalPath;
}
/// <summary>
/// Called immediately after UnrealHeaderTool is executed to generated code for all UObjects modules. Only is called if UnrealHeaderTool was actually run in this session.
/// </summary>
/// <param name="UObjectModules">List of UObject modules we generated code for.</param>
public virtual void PostCodeGeneration(UEBuildTarget Target, UHTManifest Manifest)
{
}
public virtual void PreBuildSync()
{
}
public virtual void PostBuildSync(UEBuildTarget Target)
{
}
public virtual ICollection<FileItem> PostBuild(FileItem Executable, LinkEnvironment ExecutableLinkEnvironment)
{
return new List<FileItem> ();
}
public virtual void SetUpGlobalEnvironment()
{
}
protected void RunUnrealHeaderToolIfNeeded()
{
}
public virtual void AddFilesToManifest(ref FileManifest manifest, UEBuildBinary Binary )
{
}
};
}