Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildModuleCPP.cs
Ben Marsh 30f891786a Copying //UE4/Dev-Core to //UE4/Dev-Main (Source: //UE4/Dev-Core @ 3847469)
#lockdown Nick.Penwarden
#rb none

============================
  MAJOR FEATURES & CHANGES
============================

Change 3805828 by Gil.Gribb

	UE4 - Fixed a bug in the lock free stalling task queue and adjusted a comment. The code is not current used, so this is not actually change the way the code works.

Change 3806784 by Ben.Marsh

	UAT: Remove code to compile UBT when using UE4Build. It should already be compiled as a dependency of UAT.

Change 3807549 by Graeme.Thornton

	Add a cook timer around VerifyCanCookPackage. A licensee reports this taking a lot of time so it'll be good to account for it.

Change 3807727 by Graeme.Thornton

	Unhide the text asset format experimental editor option

Change 3807746 by Josh.Engebretson

	Remove WER from iOS platform

Change 3807928 by Robert.Manuszewski

	When async loading, GC Clusters will be created after packages have been processed to avoid situations where some of the objects that are being added to a cluster haven't been fully loaded yet

Change 3808221 by Steve.Robb

	GitHub #4307 - Made GetModulePtr() thread safe by not using GetModule()

	^ I'm not convinced by how much thread-safer this is really, but it's tidier anyway.

Change 3809233 by Graeme.Thornton

	TBA: Misc changes to text asset commandlet
	 - Rename mode to "loadsave"
	 - Add -outputFormat option which can be assigned "text" or "binary"
	 - When saving binary, use a differentiated filename so that source assets aren't overwritten

Change 3809518 by Ben.Marsh

	Remove the outdated UnrealSync automation script.

Change 3809643 by Steve.Robb

	GitHub #4277 : fix bug; FMath::FormatIntToHumanReadable 3rd comma and negative value

	#jira UE-53037

Change 3809862 by Steve.Robb

	GitHub #3342 : [FRotator.h] Fix to DecompressAxisFromByte to be more efficient and reflect its intent accurately

	#jira UE-42593

Change 3811190 by Graeme.Thornton

	Add support for writing specific log channels to their own files

Change 3811197 by Graeme.Thornton

	Minor updates to output formatting and timing for the text asset commandlet

Change 3811257 by Robert.Manuszewski

	Cluster creation will now be time-sliced

Change 3811565 by Steve.Robb

	Define out non-monolithic module functions.

Change 3812561 by Steve.Robb

	GitHub #3886 : Enable Brace-Initialization for Declaring Variables

	Incorrect semi-colon search removed after discussion with author.
	Test added.

	#jira UE-48242

Change 3812864 by Steve.Robb

	Removal of some unproven code which was supposed to fix hot reloading BP class functions in plugins.

	See: https://udn.unrealengine.com/questions/376978/aitask-blueprint-nodes-disappear-when-their-module.html

	#jira UE-53089

Change 3820358 by Ben.Marsh

	PR #4358: Incredibuild use ShowAgent by default (Contributed by projectgheist)


Change 3822594 by Ben.Marsh

	UAT: Improvements to log file handling.

	- Always create log files in the final location, rather than writing to a temp directory and copying in later.
	- Now supports -Verbose and -VeryVerbose for increasing log verbosity, rather than -Verbose=XXX.
	- Keep a backlog of log output before the log system is initialized, and flush it to the log file once it is.
	- Allow buildmachines to specify the uebp_FinalLogFolder environment variable, which is used to form paths for display. When build machines copy log files elsewhere after UAT finishes (eg. a network share), this allows error messages to display the right location.

Change 3823695 by Ben.Marsh

	UGS: Fix issue where precompiled binaries would not be shown as available for a change until scrolling the last submitted code change into the buffer (other symptoms, like de-focussing the main window would cause it to go back to an unavailable state, since the changes buffer was shrunk).

	Now always queries changes up to the last change for which zipped binaries are available.

Change 3823845 by Ben.Marsh

	UBT: Exclude C# projects for unsupported platforms when generating project files.

Change 3824180 by Ben.Marsh

	UGS: Add an option to show changes by build machines, and move the "only show reviewed" option in there too (Options > Show Changes).

	#jira

Change 3825777 by Steve.Robb

	Fix to return value of StringToBytes.

Change 3825810 by Ben.Marsh

	UBT: Reduce length of include paths for MSVC toolchain.

Change 3825822 by Robert.Manuszewski

	Optimized PIE lazy pointer fixup. Should be up to 8x faster now.

Change 3826734 by Ben.Marsh

	Remove code to disable TextureFormatAndroid on Linux. It seems to be an editor dependency.

Change 3827730 by Steve.Robb

	Try to avoid decltype(auto) if it's not supported.

	See: https://udn.unrealengine.com/questions/395644/build-417-with-c11-on-linux-ttuple-errors.html

Change 3827745 by Steve.Robb

	Initializer list support for TMap.

Change 3827770 by Steve.Robb

	GitHub #4399 : Added a CONSTEXPR qualifiers to FVariant::GetType()

	#jira UE-53813

Change 3829189 by Ben.Marsh

	UBT: Now always writes a minimal log file. By default, just contains the regular console output and any reasons why actions are outdated and needed to be executed. UAT directs child UBT instances to output logs into its own log folder, so that build machines can save them off.

Change 3830444 by Steve.Robb

	BuildVersion and ModuleManifest moved to Core, and parsing of these files reimplemented to avoid a JSON library.
	This should be revisited when Core has its own JSON library.

Change 3830718 by Ben.Marsh

	Fix incorrect group name being returned by FStatNameAndInfo::GetGroupName() for stat groups.

	The editor populates the viewport stats list by calling this for every registered stat and stat group (via FLevelViewportCommands::HandleNewStatGroup). The menu entry attempts to show the stat name with STAT_XXX stripped from the start as the menu item label, with the free-form text description as a tooltip.

	For stat groups, the it would previously just return the stat group name as "Groups" (due to the raw naming convention of "//Groups//STATGROUP_Foo//..."). Since this didn't match the expected naming convention in FLevelViewportCommands::HandleNewStat (ie. STAT_XXX or STATGROUP_XXX), it would fail to add it.

	When the first actual stat belonging to that group is added, it would add a menu entry for the group based on that, but the stat description no longer makes sense as a tooltip for the group. As a result, all the editor tooltips were junk.

	#jira UE-53845

Change 3831064 by Ben.Marsh

	Fix log file contention when spawning UBT recursively.

Change 3832654 by Ben.Marsh

	UGS: Fix error panel not being selected when opened, and weird alignment/color issues on it.

Change 3832680 by Ben.Marsh

	UGS: Fix failing to detect workspace if synced to a different stream. Seems to be a regression caused by recent P4D upgrade.

Change 3832695 by Ben.Marsh

	UGS: Invert the options in the 'Show Changes' submenu for simplicity.

Change 3833528 by Ben.Marsh

	UAT: Script to rewrite source files with public include paths relative to the 'Public' folder. Usage is: RebasePublicIncludePaths -UpdateDir=<Dir> [-Project=<Dir>] [-Write].

Change 3833543 by Ben.Marsh

	UBT: Allow targets to opt-out of having public include paths added for every dependent module. This reduces the command line length when building a target, which has recently become a problem with larger games (due to Microsoft's compiler embedding the command line into each object file, with a maximum length of 64kb). All engine modules are compiled with this enabled; games may opt into it by setting bLegacyPublicIncludePaths = false; from their .target.cs, as may individual modules.

Change 3834354 by Robert.Manuszewski

	Archetype pointer will now be cached to avoid locking the object tables when acquiring its info. It should also be faster this way regardless of any locks.

	#jira UE-52035

Change 3834400 by Robert.Manuszewski

	Fixing crash on exit caused by cached archetypes not being cleaned up before static exit cleanup.

	#jira UE-52035

Change 3834947 by Steve.Robb

	USE_FORMAT_STRING_TYPE_CHECKING removed from FMsg::Logf and FMsg::Logf_Internal.

Change 3835004 by Ben.Marsh

	Fix code that relies on dubious behavior of requiring referenced "include path only" modules having their _API macros set to be empty, even if the module is actually implemented in a separate DLL.

Change 3835340 by Ben.Marsh

	Fix errors making installed build from directories with spaces in the name.

Change 3835972 by Ben.Marsh

	UBT: Improved diagnostic message for targets which don't need a version file.

Change 3836019 by Ben.Marsh

	UBT: Fix warnings caused by defining linkage macros for third party libraries.

Change 3836269 by Ben.Marsh

	Fix message box larger than the screen height being created when a large number of modules are incompatible on startup.

Change 3836543 by Ben.Marsh

	Enable SoundMod plugin on Linux, since it's already supported through the editor.

Change 3836546 by Ben.Marsh

	PR #4412: fix type mismatch (Contributed by nakapon)


Change 3836805 by Ben.Marsh

	Fix commandlet to compile marketplace plugins.

Change 3836829 by Ben.Marsh

	UBT: Fix ability to precompile plugins from installed engine builds.

Change 3837036 by Ben.Marsh

	UBT: Write the previous and new contents of intermediate files to the log if they change. Makes it easier to debug unexpected rebuilds.

Change 3837037 by Ben.Marsh

	UBT: Fix engine modules having inconsistent definitions depending on whether modules are only referenced for their include paths vs being linked into a binary (due to different _API macro).

Change 3837040 by Ben.Marsh

	UBT: Remove code that initializes members in ModuleRules and TargetRules objects before the constructor is run. This is no longer necessary, now that the backwards-compatible default constructors have been removed.

Change 3837247 by Ben.Marsh

	UBT: Remove UELinkerFixups module, now that plugins and precompiled modules do not require hacks to force initialization (since they're linked in as object files).

	Encryption and signing keys are now set via macros expanded from the IMPLEMENT_PRIMARY_GAME_MODULE macro, via project-specific macros added in the TargetRules constructor.

Change 3837262 by Ben.Marsh

	UBT: Set whether a module is an engine module or not via a default value for the rules assembly. All non-program engine and enterprise modules are created with this flag set to true; program targets and modules are now created from a different assembly that sets it to false. This removes hacks from UEBuildModule needed to adjust behavior for different module types based on the directory containing the module.

	Also add a bUseBackwardsCompatibleDefaults flag to the TargetRules class, also initialized to a default value from a setting passed to the RulesAssembly constructor. This controls whether modules created for the target should be configured to allow breaking changes to default settings, and is set to false for all engine targets, and true for all project targets.

Change 3837343 by Ben.Marsh

	UBT: Remove the OverrideExecutableFileExtension target property. Change the only current use for this (the MayaLiveLinkPlugin target) to use a post build step to copy the file instead.

Change 3837356 by Ben.Marsh

	Fix invalid character encodings.

Change 3837727 by Graeme.Thornton

	UnrealPak: KeyGenerator: Only generate prime table when required, not all the time

Change 3837823 by Ben.Marsh

	UBT: Output warnings and errors when compiling module rules assembly in a way that allows them to be double-clicked in the Visual Studio output window.

Change 3837831 by Graeme.Thornton

	UBT: When parsing crypto settings, always load legacy data first, then allow the new system to override it. Provides the same key backwards compatibility that the editor settings class gives

Change 3837857 by Robert.Manuszewski

	PR #4404: Make FGCArrayPool singleton global instead of per-CU (Contributed by mhutch)


Change 3837943 by Robert.Manuszewski

	PR #4405: Fix FGarbageCollectionTracer (Contributed by mhutch)


Change 3838451 by Ben.Marsh

	UBT: Fix exceptions thrown on a background thread while caching C++ includes not being caught and logged correctly. Now captures exceptions and re-throws on the main thread.

	#jira UE-53996

Change 3839519 by Ben.Marsh

	UBT: Simplify configuring bPrecompile and bUsePrecompile settings for modules. Each rules assembly can now be configured as installed, which defaults the module rules it creates to use precompiled data.

Change 3843790 by Graeme.Thornton

	UnrealPak: Log the size of all encrypted data

Change 3844258 by Ben.Marsh

	Fix plugin compile failure when created via new plugin wizard. Passing -plugin on the command line is unnecessary, and is now reserved for packaging external plugins for the marketplace.

	Also extend the length of time that the error toast stays visible, and don't delete the plugin on failure.

	#jira UE-54157

Change 3845796 by Ben.Marsh

	Workaround for slow performance of String.EndsWith() on Mono.

Change 3845823 by Ben.Marsh

	Fix case sensitive matching of platform names in -TargetPlatform=X argument to BuildCookRun.

	#jira UE-54123

Change 3845901 by Arciel.Rekman

	Linux: fix crash due to lambda lifetime issues (UE-54040).

	- The lambda goes out of scope in FBufferVisualizationMenuCommands::CreateVisualizationCommands, crashing the editor if compiled with a recent clang (5.0+).

	(Edigrating 3819174 to Dev-Core)

Change 3846439 by Ben.Marsh

	Revert CL 3822742 to always call Process.WaitForExit(). The Android target platform module in the editor spawns ADB.EXE, which inherits the editor's stdout/stderr handles and forks itself. Process.WaitForExit() waits for EOF on those pipes, which never occurs because the forked process never terminates.

	Proper fix is probably to have the engine explicitly duplicate stdout/stderr handles for new pipes to output process, but too risky before copying up to Main.

Change 3816608 by Ben.Marsh

	UBT: Use DirectoryReference objects for all include paths.

Change 3816954 by Ben.Marsh

	UBT: Remove bIncludeDependentLibrariesInLibrary option. This is not widely supported by platform toolchains, and is not used anywhere.

Change 3816986 by Ben.Marsh

	UBT: Remove UEBuildBinaryConfig; UEBuildBinary objects are now just created directly.

Change 3816991 by Ben.Marsh

	UBT: Deprecate PlatformSpecificDynamicallyLoadedModules. We no longer have any special behavior for these modules.

Change 3823090 by Ben.Marsh

	UAT: Improve logging for child UAT instances.

	- Calling RunUAT now requires an identifier for prefixing into the parent log, which is also used to determine the name of the log folder.
	- Stdout is no longer written to its own output file, since it's written to the parent stdout, the parent log file, and the child log file anyway.
	- Log folders for child UAT instances are left intact, rather than being copied to the parent folder. The derived names for the copied names were confusing and hard to read.
	- Output from UAT is no longer returned as a string. It should not be parsed anyway (but may be huge!). ProcessResult now supports running without capturing output.

Change 3826082 by Ben.Marsh

	UBT: Add a check to make sure that all modules that are precompiled are correctly marked to enable it, even if they are part of the build target.

Change 3827025 by Ben.Marsh

	UBT: Move the compile output directory into a property on the module, and explicitly pass it to the toolchain when compiling.

Change 3829927 by James.Hopkin

	Made HTTP interface const correct

Change 3833533 by Ben.Marsh

	Rewrite engine source files to base include paths relative to the "Public" directory. This allows reducing the number of public include paths that have to be added for engine modules.

Change 3835826 by Ben.Marsh

	UBT: Precompiled targets now generate a separate manifest for each precompiled module, rather than adding object files to a library. This fixes issues where object files from static libraries would not be linked into a target if a symbol in them was not referenced.

Change 3835969 by Ben.Marsh

	UBT: Fix cases where text is being written directly to the console rather than via logging functions.

Change 3837777 by Steve.Robb

	Format string type checking added to FOutputDevice::Logf.
	Fixes for those.

Change 3838569 by Steve.Robb

	Algo moved up a folder.

[CL 3847482 by Ben Marsh in Main branch]
2018-01-20 11:19:29 -05:00

1389 lines
58 KiB
C#

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tools.DotNETCommon;
namespace UnrealBuildTool
{
/// <summary>
/// A module that is compiled from C++ code.
/// </summary>
class UEBuildModuleCPP : UEBuildModule
{
public class AutoGenerateCppInfoClass
{
public class BuildInfoClass
{
/// <summary>
/// The wildcard of the *.gen.cpp file which was generated for the module
/// </summary>
public readonly string FileWildcard;
public BuildInfoClass(string InWildcard)
{
Debug.Assert(InWildcard != null);
FileWildcard = InWildcard;
}
}
/// <summary>
/// Information about how to build the .gen.cpp files. If this is null, then we're not building .gen.cpp files for this module.
/// </summary>
public BuildInfoClass BuildInfo;
public AutoGenerateCppInfoClass(BuildInfoClass InBuildInfo)
{
BuildInfo = InBuildInfo;
}
}
/// <summary>
/// Information about the .gen.cpp file. If this is null then this module doesn't have any UHT-produced code.
/// </summary>
public AutoGenerateCppInfoClass AutoGenerateCppInfo = null;
public class SourceFilesClass
{
public readonly List<FileItem> MissingFiles = new List<FileItem>();
public readonly List<FileItem> CPPFiles = new List<FileItem>();
public readonly List<FileItem> CFiles = new List<FileItem>();
public readonly List<FileItem> CCFiles = new List<FileItem>();
public readonly List<FileItem> MMFiles = new List<FileItem>();
public readonly List<FileItem> RCFiles = new List<FileItem>();
public readonly List<FileItem> OtherFiles = new List<FileItem>();
public int Count
{
get
{
return MissingFiles.Count +
CPPFiles.Count +
CFiles.Count +
CCFiles.Count +
MMFiles.Count +
RCFiles.Count +
OtherFiles.Count;
}
}
/// <summary>
/// Copy from list to list helper.
/// </summary>
/// <param name="From">Source list.</param>
/// <param name="To">Destination list.</param>
private static void CopyFromListToList(List<FileItem> From, List<FileItem> To)
{
To.Clear();
To.AddRange(From);
}
/// <summary>
/// Copies file lists from other SourceFilesClass to this.
/// </summary>
/// <param name="Other">Source object.</param>
public void CopyFrom(SourceFilesClass Other)
{
CopyFromListToList(Other.MissingFiles, MissingFiles);
CopyFromListToList(Other.CPPFiles, CPPFiles);
CopyFromListToList(Other.CFiles, CFiles);
CopyFromListToList(Other.CCFiles, CCFiles);
CopyFromListToList(Other.MMFiles, MMFiles);
CopyFromListToList(Other.RCFiles, RCFiles);
CopyFromListToList(Other.OtherFiles, OtherFiles);
}
}
/// <summary>
/// Adds additional source cpp files for this module.
/// </summary>
/// <param name="Files">Files to add.</param>
public void AddAdditionalCPPFiles(IEnumerable<FileItem> Files)
{
SourceFiles.AddRange(Files);
SourceFilesToBuild.CPPFiles.AddRange(Files);
}
/// <summary>
/// All the source files for this module
/// </summary>
public readonly List<FileItem> SourceFiles = new List<FileItem>();
/// <summary>
/// A list of the absolute paths of source files to be built in this module.
/// </summary>
public readonly SourceFilesClass SourceFilesToBuild = new SourceFilesClass();
/// <summary>
/// A list of the source files that were found for the module.
/// </summary>
public readonly SourceFilesClass SourceFilesFound = new SourceFilesClass();
/// <summary>
/// The directory for this module's object files
/// </summary>
public readonly DirectoryReference IntermediateDirectory;
/// <summary>
/// The directory for this module's generated code
/// </summary>
public readonly DirectoryReference GeneratedCodeDirectory;
public List<DirectoryReference> IncludeSearchPaths = new List<DirectoryReference>();
public class ProcessedDependenciesClass
{
/// <summary>
/// The file, if any, which is used as the unique PCH for this module
/// </summary>
public FileItem UniquePCHHeaderFile = null;
}
/// <summary>
/// The processed dependencies for the class
/// </summary>
public ProcessedDependenciesClass ProcessedDependencies = null;
/// <summary>
/// List of invalid include directives. These are buffered up and output before we start compiling.
/// </summary>
public List<string> InvalidIncludeDirectiveMessages;
/// <summary>
/// Hack to skip adding definitions to compile environment. They will be baked into source code by external code.
/// </summary>
public bool bSkipDefinitionsForCompileEnvironment = false;
public IEnumerable<string> FindGeneratedCppFiles()
{
return ((null == GeneratedCodeDirectory) || !DirectoryReference.Exists(GeneratedCodeDirectory))
? Enumerable.Empty<string>()
: DirectoryReference.EnumerateFiles(GeneratedCodeDirectory, "*.gen.cpp", SearchOption.TopDirectoryOnly).Select((Dir) => Dir.FullName);
}
protected override void GetReferencedDirectories(HashSet<DirectoryReference> Directories)
{
base.GetReferencedDirectories(Directories);
foreach(FileItem SourceFile in SourceFiles)
{
Directories.Add(SourceFile.Location.Directory);
}
}
/// <summary>
/// Categorizes source files into per-extension buckets
/// </summary>
private static void CategorizeSourceFiles(IEnumerable<FileItem> InSourceFiles, SourceFilesClass OutSourceFiles)
{
foreach (FileItem SourceFile in InSourceFiles)
{
string Extension = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant();
if (!SourceFile.bExists)
{
OutSourceFiles.MissingFiles.Add(SourceFile);
}
else if (Extension == ".CPP")
{
OutSourceFiles.CPPFiles.Add(SourceFile);
}
else if (Extension == ".C")
{
OutSourceFiles.CFiles.Add(SourceFile);
}
else if (Extension == ".CC")
{
OutSourceFiles.CCFiles.Add(SourceFile);
}
else if (Extension == ".MM" || Extension == ".M")
{
OutSourceFiles.MMFiles.Add(SourceFile);
}
else if (Extension == ".RC")
{
OutSourceFiles.RCFiles.Add(SourceFile);
}
else
{
OutSourceFiles.OtherFiles.Add(SourceFile);
}
}
}
/// <summary>
/// List of whitelisted circular dependencies. Please do NOT add new modules here; refactor to allow the modules to be decoupled instead.
/// </summary>
static readonly KeyValuePair<string, string>[] WhitelistedCircularDependencies =
{
new KeyValuePair<string, string>("Engine", "AIModule"),
new KeyValuePair<string, string>("Engine", "Landscape"),
new KeyValuePair<string, string>("Engine", "UMG"),
new KeyValuePair<string, string>("Engine", "GameplayTags"),
new KeyValuePair<string, string>("Engine", "MaterialShaderQualitySettings"),
new KeyValuePair<string, string>("Engine", "UnrealEd"),
new KeyValuePair<string, string>("PacketHandler", "ReliabilityHandlerComponent"),
new KeyValuePair<string, string>("GameplayDebugger", "AIModule"),
new KeyValuePair<string, string>("GameplayDebugger", "GameplayTasks"),
new KeyValuePair<string, string>("Engine", "CinematicCamera"),
new KeyValuePair<string, string>("Engine", "CollisionAnalyzer"),
new KeyValuePair<string, string>("Engine", "LogVisualizer"),
new KeyValuePair<string, string>("Engine", "Kismet"),
new KeyValuePair<string, string>("Landscape", "UnrealEd"),
new KeyValuePair<string, string>("Landscape", "MaterialUtilities"),
new KeyValuePair<string, string>("LocalizationDashboard", "LocalizationService"),
new KeyValuePair<string, string>("LocalizationDashboard", "MainFrame"),
new KeyValuePair<string, string>("LocalizationDashboard", "TranslationEditor"),
new KeyValuePair<string, string>("Documentation", "SourceControl"),
new KeyValuePair<string, string>("UnrealEd", "GraphEditor"),
new KeyValuePair<string, string>("UnrealEd", "Kismet"),
new KeyValuePair<string, string>("UnrealEd", "AudioEditor"),
new KeyValuePair<string, string>("BlueprintGraph", "KismetCompiler"),
new KeyValuePair<string, string>("BlueprintGraph", "UnrealEd"),
new KeyValuePair<string, string>("BlueprintGraph", "GraphEditor"),
new KeyValuePair<string, string>("BlueprintGraph", "Kismet"),
new KeyValuePair<string, string>("BlueprintGraph", "CinematicCamera"),
new KeyValuePair<string, string>("ConfigEditor", "PropertyEditor"),
new KeyValuePair<string, string>("SourceControl", "UnrealEd"),
new KeyValuePair<string, string>("Kismet", "BlueprintGraph"),
new KeyValuePair<string, string>("Kismet", "UMGEditor"),
new KeyValuePair<string, string>("MovieSceneTools", "Sequencer"),
new KeyValuePair<string, string>("Sequencer", "MovieSceneTools"),
new KeyValuePair<string, string>("AIModule", "AITestSuite"),
new KeyValuePair<string, string>("GameplayTasks", "UnrealEd"),
new KeyValuePair<string, string>("AnimGraph", "UnrealEd"),
new KeyValuePair<string, string>("AnimGraph", "GraphEditor"),
new KeyValuePair<string, string>("MaterialUtilities", "Landscape"),
new KeyValuePair<string, string>("HierarchicalLODOutliner", "UnrealEd"),
new KeyValuePair<string, string>("PixelInspectorModule", "UnrealEd"),
new KeyValuePair<string, string>("GameplayAbilitiesEditor", "BlueprintGraph"),
new KeyValuePair<string, string>("UnrealEd", "ViewportInteraction"),
new KeyValuePair<string, string>("UnrealEd", "VREditor"),
new KeyValuePair<string, string>("LandscapeEditor", "ViewportInteraction"),
new KeyValuePair<string, string>("LandscapeEditor", "VREditor"),
new KeyValuePair<string, string>("FoliageEdit", "ViewportInteraction"),
new KeyValuePair<string, string>("FoliageEdit", "VREditor"),
new KeyValuePair<string, string>("MeshPaint", "ViewportInteraction"),
new KeyValuePair<string, string>("MeshPaint", "VREditor"),
new KeyValuePair<string, string>("MeshPaintMode", "ViewportInteraction"),
new KeyValuePair<string, string>("MeshPaintMode", "VREditor"),
new KeyValuePair<string, string>("Sequencer", "ViewportInteraction"),
};
public UEBuildModuleCPP(
string InName,
UHTModuleType InType,
DirectoryReference InModuleDirectory,
DirectoryReference InIntermediateDirectory,
DirectoryReference InGeneratedCodeDirectory,
IEnumerable<FileItem> InSourceFiles,
ModuleRules InRules,
bool bInBuildSourceFiles,
FileReference InRulesFile,
List<RuntimeDependency> InRuntimeDependencies
)
: base(
InName,
InType,
InModuleDirectory,
InRules,
InRulesFile,
InRuntimeDependencies
)
{
IntermediateDirectory = InIntermediateDirectory;
GeneratedCodeDirectory = InGeneratedCodeDirectory;
SourceFiles = InSourceFiles.ToList();
CategorizeSourceFiles(InSourceFiles, SourceFilesFound);
if (bInBuildSourceFiles)
{
SourceFilesToBuild.CopyFrom(SourceFilesFound);
}
foreach (string Def in PublicDefinitions)
{
Log.TraceVerbose("Compile Env {0}: {1}", Name, Def);
}
foreach (string Def in Rules.PrivateDefinitions)
{
Log.TraceVerbose("Compile Env {0}: {1}", Name, Def);
}
foreach(string CircularlyReferencedModuleName in Rules.CircularlyReferencedDependentModules)
{
if(CircularlyReferencedModuleName != "BlueprintContext" && !WhitelistedCircularDependencies.Any(x => x.Key == Name && x.Value == CircularlyReferencedModuleName))
{
Log.TraceWarning("Found reference between '{0}' and '{1}'. Support for circular references is being phased out; please do not introduce new ones.", Name, CircularlyReferencedModuleName);
}
}
AddDefaultIncludePaths();
}
/// <summary>
/// Add the default include paths for this module to its settings
/// </summary>
private void AddDefaultIncludePaths()
{
// Add the path to the generated headers
if (GeneratedCodeDirectory != null)
{
PublicIncludePaths.Add(GeneratedCodeDirectory);
}
// Add the module's parent directory to the public include paths, so other modules may include headers from it explicitly.
PublicIncludePaths.Add(ModuleDirectory.ParentDirectory);
// Add the base directory to the legacy include paths.
LegacyPublicIncludePaths.Add(ModuleDirectory);
// Add the 'classes' directory, if it exists
DirectoryReference ClassesDirectory = DirectoryReference.Combine(ModuleDirectory, "Classes");
if (DirectoryLookupCache.DirectoryExists(ClassesDirectory))
{
PublicIncludePaths.Add(ClassesDirectory);
}
// Add all the public directories
DirectoryReference PublicDirectory = DirectoryReference.Combine(ModuleDirectory, "Public");
if (DirectoryLookupCache.DirectoryExists(PublicDirectory))
{
PublicIncludePaths.Add(PublicDirectory);
FileSystemName[] ExcludedFolderNames = UEBuildPlatform.GetBuildPlatform(Rules.Target.Platform).GetExcludedFolderNames();
foreach (DirectoryReference PublicSubDirectory in DirectoryLookupCache.EnumerateDirectoriesRecursively(PublicDirectory))
{
if(!PublicSubDirectory.ContainsAnyNames(ExcludedFolderNames, PublicDirectory))
{
LegacyPublicIncludePaths.Add(PublicSubDirectory);
}
}
}
// Add the base private directory for this module
DirectoryReference PrivateDirectory = DirectoryReference.Combine(ModuleDirectory, "Private");
if(DirectoryLookupCache.DirectoryExists(PrivateDirectory))
{
PrivateIncludePaths.Add(PrivateDirectory);
}
}
/// <summary>
/// Path to the precompiled manifest location
/// </summary>
public FileReference PrecompiledManifestLocation
{
get { return FileReference.Combine(IntermediateDirectory, String.Format("{0}.precompiled", Name)); }
}
/// <summary>
/// Gathers intellisense data for the project file containing this module
/// </summary>
/// <param name="Target">The target being built</param>
/// <param name="BinaryCompileEnvironment">The inherited compile environment for this module</param>
/// <param name="ProjectFile">The project file containing this module</param>
public void GatherDataForProjectFile(ReadOnlyTargetRules Target, CppCompileEnvironment BinaryCompileEnvironment, ProjectFile ProjectFile)
{
CppCompileEnvironment ModuleCompileEnvironment = CreateModuleCompileEnvironment(Target, BinaryCompileEnvironment);
ProjectFile.AddIntelliSensePreprocessorDefinitions(ModuleCompileEnvironment.Definitions);
ProjectFile.AddInteliiSenseIncludePaths(ModuleCompileEnvironment.IncludePaths.SystemIncludePaths, true);
ProjectFile.AddInteliiSenseIncludePaths(ModuleCompileEnvironment.IncludePaths.UserIncludePaths, false);
}
// UEBuildModule interface.
public override List<FileItem> Compile(ReadOnlyTargetRules Target, UEToolChain ToolChain, CppCompileEnvironment BinaryCompileEnvironment, List<PrecompiledHeaderTemplate> SharedPCHs, ISourceFileWorkingSet WorkingSet, ActionGraph ActionGraph)
{
UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(BinaryCompileEnvironment.Platform);
List<FileItem> LinkInputFiles = new List<FileItem>();
CppCompileEnvironment ModuleCompileEnvironment = CreateModuleCompileEnvironment(Target, BinaryCompileEnvironment);
IncludeSearchPaths = ModuleCompileEnvironment.IncludePaths.UserIncludePaths.ToList();
IncludeSearchPaths.AddRange(ModuleCompileEnvironment.IncludePaths.SystemIncludePaths.ToList());
// If the module is precompiled, read the object files from the manifest
if(Rules.bUsePrecompiled)
{
PrecompiledManifest Manifest = PrecompiledManifest.Read(PrecompiledManifestLocation);
foreach(FileReference OutputFile in Manifest.OutputFiles)
{
FileItem ObjectFile = FileItem.GetExistingItemByFileReference(OutputFile);
LinkInputFiles.Add(ObjectFile);
}
return LinkInputFiles;
}
// Throw an error if the module's source file list referenced any non-existent files.
if (SourceFilesToBuild.MissingFiles.Count > 0)
{
throw new BuildException(
"UBT ERROR: Module \"{0}\" references non-existent files:\n{1} (perhaps a file was added to the project but not checked in)",
Name,
string.Join("\n", SourceFilesToBuild.MissingFiles.Select(M => M.AbsolutePath))
);
}
{
// Process all of the header file dependencies for this module
this.CachePCHUsageForModuleSourceFiles(Target, ModuleCompileEnvironment);
// Make sure our RC files have cached includes.
foreach (FileItem RCFile in SourceFilesToBuild.RCFiles)
{
// The default resource file (PCLaunch.rc) is created in a module-agnostic way, so we want to avoid overriding the include paths for it
if(RCFile.CachedIncludePaths == null)
{
RCFile.CachedIncludePaths = ModuleCompileEnvironment.IncludePaths;
}
}
}
// Should we force a precompiled header to be generated for this module? Usually, we only bother with a
// precompiled header if there are at least several source files in the module (after combining them for unity
// builds.) But for game modules, it can be convenient to always have a precompiled header to single-file
// changes to code is really quick to compile.
int MinFilesUsingPrecompiledHeader = Target.MinFilesUsingPrecompiledHeader;
if (Rules.MinFilesUsingPrecompiledHeaderOverride != 0)
{
MinFilesUsingPrecompiledHeader = Rules.MinFilesUsingPrecompiledHeaderOverride;
}
else if (!Rules.bTreatAsEngineModule && Target.bForcePrecompiledHeaderForGameModules)
{
// This is a game module with only a small number of source files, so go ahead and force a precompiled header
// to be generated to make incremental changes to source files as fast as possible for small projects.
MinFilesUsingPrecompiledHeader = 1;
}
// Engine modules will always use unity build mode unless MinSourceFilesForUnityBuildOverride is specified in
// the module rules file. By default, game modules only use unity of they have enough source files for that
// to be worthwhile. If you have a lot of small game modules, consider specifying MinSourceFilesForUnityBuildOverride=0
// in the modules that you don't typically iterate on source files in very frequently.
int MinSourceFilesForUnityBuild = 0;
if (Rules.MinSourceFilesForUnityBuildOverride != 0)
{
MinSourceFilesForUnityBuild = Rules.MinSourceFilesForUnityBuildOverride;
}
else if (!Rules.bTreatAsEngineModule)
{
// Game modules with only a small number of source files are usually better off having faster iteration times
// on single source file changes, so we forcibly disable unity build for those modules
MinSourceFilesForUnityBuild = Target.MinGameModuleSourceFilesForUnityBuild;
}
// Should we use unity build mode for this module?
bool bModuleUsesUnityBuild = false;
if (Target.bUseUnityBuild || Target.bForceUnityBuild)
{
if (Target.bForceUnityBuild)
{
Log.TraceVerbose("Module '{0}' using unity build mode (bForceUnityBuild enabled for this module)", this.Name);
bModuleUsesUnityBuild = true;
}
else if (Rules.bFasterWithoutUnity)
{
Log.TraceVerbose("Module '{0}' not using unity build mode (bFasterWithoutUnity enabled for this module)", this.Name);
bModuleUsesUnityBuild = false;
}
else if (SourceFilesToBuild.CPPFiles.Count < MinSourceFilesForUnityBuild)
{
Log.TraceVerbose("Module '{0}' not using unity build mode (module with fewer than {1} source files)", this.Name, MinSourceFilesForUnityBuild);
bModuleUsesUnityBuild = false;
}
else
{
Log.TraceVerbose("Module '{0}' using unity build mode", this.Name);
bModuleUsesUnityBuild = true;
}
}
else
{
Log.TraceVerbose("Module '{0}' not using unity build mode", this.Name);
}
// Set up the environment with which to compile the CPP files
CppCompileEnvironment CompileEnvironment = ModuleCompileEnvironment;
if (Target.bUsePCHFiles)
{
// If this module has an explicit PCH, use that
if(Rules.PrivatePCHHeaderFile != null)
{
PrecompiledHeaderInstance Instance = CreatePrivatePCH(ToolChain, FileItem.GetItemByFileReference(FileReference.Combine(ModuleDirectory, Rules.PrivatePCHHeaderFile)), CompileEnvironment, ActionGraph);
CompileEnvironment = new CppCompileEnvironment(CompileEnvironment);
CompileEnvironment.Definitions.Clear();
CompileEnvironment.PrecompiledHeaderAction = PrecompiledHeaderAction.Include;
CompileEnvironment.PrecompiledHeaderIncludeFilename = Instance.HeaderFile.Location;
CompileEnvironment.PrecompiledHeaderFile = Instance.Output.PrecompiledHeaderFile;
LinkInputFiles.AddRange(Instance.Output.ObjectFiles);
}
// Try to find a suitable shared PCH for this module
if (CompileEnvironment.PrecompiledHeaderFile == null && SharedPCHs.Count > 0 && !CompileEnvironment.bIsBuildingLibrary && Rules.PCHUsage != ModuleRules.PCHUsageMode.NoSharedPCHs)
{
// Find all the dependencies of this module
HashSet<UEBuildModule> ReferencedModules = new HashSet<UEBuildModule>();
GetAllDependencyModules(new List<UEBuildModule>(), ReferencedModules, bIncludeDynamicallyLoaded: false, bForceCircular: false, bOnlyDirectDependencies: true);
// Find the first shared PCH module we can use
PrecompiledHeaderTemplate Template = SharedPCHs.FirstOrDefault(x => ReferencedModules.Contains(x.Module));
if(Template != null && Template.IsValidFor(CompileEnvironment))
{
PrecompiledHeaderInstance Instance = FindOrCreateSharedPCH(ToolChain, Template, ModuleCompileEnvironment.bOptimizeCode, ModuleCompileEnvironment.bUseRTTI, ActionGraph);
FileReference PrivateDefinitionsFile = FileReference.Combine(IntermediateDirectory, String.Format("Definitions.{0}.h", Name));
using (StringWriter Writer = new StringWriter())
{
// Remove the module _API definition for cases where there are circular dependencies between the shared PCH module and modules using it
Writer.WriteLine("#undef {0}", ModuleApiDefine);
// Games may choose to use shared PCHs from the engine, so allow them to change the value of these macros
if(!Rules.bTreatAsEngineModule)
{
Writer.WriteLine("#undef UE_IS_ENGINE_MODULE");
Writer.WriteLine("#undef DEPRECATED_FORGAME");
Writer.WriteLine("#define DEPRECATED_FORGAME DEPRECATED");
}
WriteDefinitions(CompileEnvironment.Definitions, Writer);
FileItem.CreateIntermediateTextFile(PrivateDefinitionsFile, Writer.ToString());
}
CompileEnvironment = new CppCompileEnvironment(CompileEnvironment);
CompileEnvironment.Definitions.Clear();
CompileEnvironment.ForceIncludeFiles.Add(PrivateDefinitionsFile);
CompileEnvironment.PrecompiledHeaderAction = PrecompiledHeaderAction.Include;
CompileEnvironment.PrecompiledHeaderIncludeFilename = Instance.HeaderFile.Location;
CompileEnvironment.PrecompiledHeaderFile = Instance.Output.PrecompiledHeaderFile;
LinkInputFiles.AddRange(Instance.Output.ObjectFiles);
}
}
// If there was one header that was included first by enough C++ files, use it as the precompiled header. Only use precompiled headers for projects with enough files to make the PCH creation worthwhile.
if (CompileEnvironment.PrecompiledHeaderFile == null && SourceFilesToBuild.CPPFiles.Count >= MinFilesUsingPrecompiledHeader && ProcessedDependencies != null)
{
PrecompiledHeaderInstance Instance = CreatePrivatePCH(ToolChain, ProcessedDependencies.UniquePCHHeaderFile, CompileEnvironment, ActionGraph);
CompileEnvironment = new CppCompileEnvironment(CompileEnvironment);
CompileEnvironment.Definitions.Clear();
CompileEnvironment.PrecompiledHeaderAction = PrecompiledHeaderAction.Include;
CompileEnvironment.PrecompiledHeaderIncludeFilename = Instance.HeaderFile.Location;
CompileEnvironment.PrecompiledHeaderFile = Instance.Output.PrecompiledHeaderFile;
LinkInputFiles.AddRange(Instance.Output.ObjectFiles);
}
}
// Compile CPP files
List<FileItem> CPPFilesToCompile = SourceFilesToBuild.CPPFiles;
if (bModuleUsesUnityBuild)
{
CPPFilesToCompile = Unity.GenerateUnityCPPs(Target, CPPFilesToCompile, CompileEnvironment, WorkingSet, Rules.ShortName ?? Name, IntermediateDirectory);
LinkInputFiles.AddRange(CompileUnityFilesWithToolChain(Target, ToolChain, CompileEnvironment, ModuleCompileEnvironment, CPPFilesToCompile, ActionGraph).ObjectFiles);
}
else
{
LinkInputFiles.AddRange(ToolChain.CompileCPPFiles(CompileEnvironment, CPPFilesToCompile, IntermediateDirectory, Name, ActionGraph).ObjectFiles);
}
// Compile all the generated CPP files
if (AutoGenerateCppInfo != null && AutoGenerateCppInfo.BuildInfo != null && !CompileEnvironment.bHackHeaderGenerator)
{
string[] GeneratedFiles = Directory.GetFiles(Path.GetDirectoryName(AutoGenerateCppInfo.BuildInfo.FileWildcard), Path.GetFileName(AutoGenerateCppInfo.BuildInfo.FileWildcard));
if(GeneratedFiles.Length > 0)
{
// Create a compile environment for the generated files. We can disable creating debug info here to improve link times.
CppCompileEnvironment GeneratedCPPCompileEnvironment = CompileEnvironment;
if(GeneratedCPPCompileEnvironment.bCreateDebugInfo && Target.bDisableDebugInfoForGeneratedCode)
{
GeneratedCPPCompileEnvironment = new CppCompileEnvironment(GeneratedCPPCompileEnvironment);
GeneratedCPPCompileEnvironment.bCreateDebugInfo = false;
}
// Compile all the generated files
List<FileItem> GeneratedFileItems = new List<FileItem>();
foreach (string GeneratedFilename in GeneratedFiles)
{
FileItem GeneratedCppFileItem = FileItem.GetItemByPath(GeneratedFilename);
CachePCHUsageForModuleSourceFile(CompileEnvironment, GeneratedCppFileItem);
// @todo ubtmake: Check for ALL other places where we might be injecting .cpp or .rc files for compiling without caching CachedCPPIncludeInfo first (anything platform specific?)
GeneratedFileItems.Add(GeneratedCppFileItem);
}
if (bModuleUsesUnityBuild)
{
GeneratedFileItems = Unity.GenerateUnityCPPs(Target, GeneratedFileItems, GeneratedCPPCompileEnvironment, WorkingSet, (Rules.ShortName ?? Name) + ".gen", IntermediateDirectory);
LinkInputFiles.AddRange(CompileUnityFilesWithToolChain(Target, ToolChain, GeneratedCPPCompileEnvironment, ModuleCompileEnvironment, GeneratedFileItems, ActionGraph).ObjectFiles);
}
else
{
LinkInputFiles.AddRange(ToolChain.CompileCPPFiles(GeneratedCPPCompileEnvironment, GeneratedFileItems, IntermediateDirectory, Name, ActionGraph).ObjectFiles);
}
}
}
// Compile C files directly. Do not use a PCH here, because a C++ PCH is not compatible with C source files.
LinkInputFiles.AddRange(ToolChain.CompileCPPFiles(ModuleCompileEnvironment, SourceFilesToBuild.CFiles, IntermediateDirectory, Name, ActionGraph).ObjectFiles);
// Compile CC files directly.
LinkInputFiles.AddRange(ToolChain.CompileCPPFiles(CompileEnvironment, SourceFilesToBuild.CCFiles, IntermediateDirectory, Name, ActionGraph).ObjectFiles);
// Compile MM files directly.
LinkInputFiles.AddRange(ToolChain.CompileCPPFiles(CompileEnvironment, SourceFilesToBuild.MMFiles, IntermediateDirectory, Name, ActionGraph).ObjectFiles);
// Compile RC files. The resource compiler does not work with response files, and using the regular compile environment can easily result in the
// command line length exceeding the OS limit. Use the binary compile environment to keep the size down, and require that all include paths
// must be specified relative to the resource file itself or Engine/Source.
CppCompileEnvironment ResourceCompileEnvironment = new CppCompileEnvironment(BinaryCompileEnvironment);
LinkInputFiles.AddRange(ToolChain.CompileRCFiles(ResourceCompileEnvironment, SourceFilesToBuild.RCFiles, IntermediateDirectory, ActionGraph).ObjectFiles);
// Write the compiled manifest
if(Rules.bPrecompile)
{
DirectoryReference.CreateDirectory(PrecompiledManifestLocation.Directory);
PrecompiledManifest Manifest = new PrecompiledManifest();
Manifest.OutputFiles.AddRange(LinkInputFiles.Select(x => x.Location));
Manifest.Write(PrecompiledManifestLocation);
}
return LinkInputFiles;
}
/// <summary>
/// Create a shared PCH template for this module, which allows constructing shared PCH instances in the future
/// </summary>
/// <param name="Target">The target which owns this module</param>
/// <param name="BaseCompileEnvironment">Base compile environment for this target</param>
/// <returns>Template for shared PCHs</returns>
public PrecompiledHeaderTemplate CreateSharedPCHTemplate(UEBuildTarget Target, CppCompileEnvironment BaseCompileEnvironment)
{
CppCompileEnvironment CompileEnvironment = CreateSharedPCHCompileEnvironment(Target, BaseCompileEnvironment);
FileItem HeaderFile = FileItem.GetItemByFileReference(FileReference.Combine(ModuleDirectory, Rules.SharedPCHHeaderFile));
HeaderFile.CachedIncludePaths = CompileEnvironment.IncludePaths;
DirectoryReference PrecompiledHeaderDir;
if(Target.Rules.bUsePrecompiled)
{
PrecompiledHeaderDir = DirectoryReference.Combine(Target.ProjectIntermediateDirectory, Name);
}
else
{
PrecompiledHeaderDir = IntermediateDirectory;
}
return new PrecompiledHeaderTemplate(this, CompileEnvironment, HeaderFile, PrecompiledHeaderDir);
}
/// <summary>
/// Creates a precompiled header action to generate a new pch file
/// </summary>
/// <param name="ToolChain">The toolchain to generate the PCH</param>
/// <param name="HeaderFile"></param>
/// <param name="ModuleCompileEnvironment"></param>
/// <param name="ActionGraph">Graph containing build actions</param>
/// <returns>The created PCH instance.</returns>
private PrecompiledHeaderInstance CreatePrivatePCH(UEToolChain ToolChain, FileItem HeaderFile, CppCompileEnvironment ModuleCompileEnvironment, ActionGraph ActionGraph)
{
// Cache the header file include paths. This file could have been a shared PCH too, so ignore if the include paths are already set.
if(HeaderFile.CachedIncludePaths == null)
{
HeaderFile.CachedIncludePaths = ModuleCompileEnvironment.IncludePaths;
}
// Create the wrapper file, which sets all the definitions needed to compile it
FileReference WrapperLocation = FileReference.Combine(IntermediateDirectory, String.Format("PCH.{0}.h", Name));
FileItem WrapperFile = CreatePCHWrapperFile(WrapperLocation, ModuleCompileEnvironment.Definitions, HeaderFile);
// Create a new C++ environment that is used to create the PCH.
CppCompileEnvironment CompileEnvironment = new CppCompileEnvironment(ModuleCompileEnvironment);
CompileEnvironment.Definitions.Clear();
CompileEnvironment.PrecompiledHeaderAction = PrecompiledHeaderAction.Create;
CompileEnvironment.PrecompiledHeaderIncludeFilename = WrapperFile.Location;
CompileEnvironment.bOptimizeCode = ModuleCompileEnvironment.bOptimizeCode;
// Create the action to compile the PCH file.
CPPOutput Output = ToolChain.CompileCPPFiles(CompileEnvironment, new List<FileItem>() { WrapperFile }, IntermediateDirectory, Name, ActionGraph);
return new PrecompiledHeaderInstance(WrapperFile, CompileEnvironment.bOptimizeCode, CompileEnvironment.bUseRTTI, Output);
}
/// <summary>
/// Generates a precompiled header instance from the given template, or returns an existing one if it already exists
/// </summary>
/// <param name="ToolChain">The toolchain being used to build this module</param>
/// <param name="Template">The PCH template</param>
/// <param name="bOptimizeCode">Whether optimization should be enabled for this PCH</param>
/// <param name="bUseRTTI">Whether to enable RTTI for this PCH</param>
/// <param name="ActionGraph">Graph containing build actions</param>
/// <returns>Instance of a PCH</returns>
public PrecompiledHeaderInstance FindOrCreateSharedPCH(UEToolChain ToolChain, PrecompiledHeaderTemplate Template, bool bOptimizeCode, bool bUseRTTI, ActionGraph ActionGraph)
{
PrecompiledHeaderInstance Instance = Template.Instances.Find(x => x.bOptimizeCode == bOptimizeCode && x.bUseRTTI == bUseRTTI);
if(Instance == null)
{
// Create a suffix to distinguish this shared PCH variant from any others. Currently only optimized and non-optimized shared PCHs are supported.
string Variant = "";
if(bOptimizeCode != Template.BaseCompileEnvironment.bOptimizeCode)
{
if(bOptimizeCode)
{
Variant += ".Optimized";
}
else
{
Variant += ".NonOptimized";
}
}
if(bUseRTTI != Template.BaseCompileEnvironment.bUseRTTI)
{
if (bUseRTTI)
{
Variant += ".RTTI";
}
else
{
Variant += ".NonRTTI";
}
}
// Create the wrapper file, which sets all the definitions needed to compile it
FileReference WrapperLocation = FileReference.Combine(Template.OutputDir, String.Format("SharedPCH.{0}{1}.h", Template.Module.Name, Variant));
FileItem WrapperFile = CreatePCHWrapperFile(WrapperLocation, Template.BaseCompileEnvironment.Definitions, Template.HeaderFile);
// Create the compile environment for this PCH
CppCompileEnvironment CompileEnvironment = new CppCompileEnvironment(Template.BaseCompileEnvironment);
CompileEnvironment.Definitions.Clear();
CompileEnvironment.PrecompiledHeaderAction = PrecompiledHeaderAction.Create;
CompileEnvironment.PrecompiledHeaderIncludeFilename = WrapperFile.Location;
CompileEnvironment.bOptimizeCode = bOptimizeCode;
CompileEnvironment.bUseRTTI = bUseRTTI;
// Create the PCH
CPPOutput Output = ToolChain.CompileCPPFiles(CompileEnvironment, new List<FileItem>() { WrapperFile }, Template.OutputDir, "Shared", ActionGraph);
Instance = new PrecompiledHeaderInstance(WrapperFile, bOptimizeCode, bUseRTTI, Output);
Template.Instances.Add(Instance);
}
return Instance;
}
/// <summary>
/// Compiles the provided CPP unity files. Will
/// </summary>
private CPPOutput CompileUnityFilesWithToolChain(ReadOnlyTargetRules Target, UEToolChain ToolChain, CppCompileEnvironment CompileEnvironment, CppCompileEnvironment ModuleCompileEnvironment, List<FileItem> SourceFiles, ActionGraph ActionGraph)
{
List<FileItem> NormalFiles = new List<FileItem>();
List<FileItem> AdaptiveFiles = new List<FileItem>();
bool bAdaptiveUnityDisablesPCH = (Target.bAdaptiveUnityDisablesPCH && Rules.PCHUsage == ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs);
if ((Target.bAdaptiveUnityDisablesOptimizations || bAdaptiveUnityDisablesPCH) && !Target.bStressTestUnity)
{
foreach (FileItem File in SourceFiles)
{
// Basic check as to whether something in this module is/isn't a unity file...
if (File.Location.GetFileName().StartsWith(Unity.ModulePrefix))
{
NormalFiles.Add(File);
}
else
{
AdaptiveFiles.Add(File);
}
}
}
else
{
NormalFiles.AddRange(SourceFiles);
}
CPPOutput OutputFiles = new CPPOutput();
if (NormalFiles.Count > 0)
{
OutputFiles = ToolChain.CompileCPPFiles(CompileEnvironment, NormalFiles, IntermediateDirectory, Name, ActionGraph);
}
if (AdaptiveFiles.Count > 0)
{
// Create the new compile environment. Always turn off PCH due to different compiler settings.
CppCompileEnvironment AdaptiveUnityEnvironment = new CppCompileEnvironment(ModuleCompileEnvironment);
if(Target.bAdaptiveUnityDisablesOptimizations)
{
AdaptiveUnityEnvironment.bOptimizeCode = false;
}
AdaptiveUnityEnvironment.PrecompiledHeaderAction = PrecompiledHeaderAction.None;
// Compile the files
CPPOutput AdaptiveOutput = ToolChain.CompileCPPFiles(AdaptiveUnityEnvironment, AdaptiveFiles, IntermediateDirectory, Name, ActionGraph);
// Merge output
OutputFiles.ObjectFiles.AddRange(AdaptiveOutput.ObjectFiles);
OutputFiles.DebugDataFiles.AddRange(AdaptiveOutput.DebugDataFiles);
}
return OutputFiles;
}
/// <summary>
/// Create a header file containing the module definitions, which also includes the PCH itself. Including through another file is necessary on
/// Clang, since we get warnings about #pragma once otherwise, but it also allows us to consistently define the preprocessor state on all
/// platforms.
/// </summary>
/// <param name="OutputFile">The output file to create</param>
/// <param name="Definitions">Definitions required by the PCH</param>
/// <param name="IncludedFile">The PCH file to include</param>
/// <returns>FileItem for the created file</returns>
static FileItem CreatePCHWrapperFile(FileReference OutputFile, IEnumerable<string> Definitions, FileItem IncludedFile)
{
// Build the contents of the wrapper file
StringBuilder WrapperContents = new StringBuilder();
using (StringWriter Writer = new StringWriter(WrapperContents))
{
Writer.WriteLine("// PCH for {0}", IncludedFile.AbsolutePath);
WriteDefinitions(Definitions, Writer);
Writer.WriteLine("#include \"{0}\"", IncludedFile.AbsolutePath);
}
// Create the item
FileItem WrapperFile = FileItem.CreateIntermediateTextFile(OutputFile, WrapperContents.ToString());
WrapperFile.CachedIncludePaths = IncludedFile.CachedIncludePaths;
// Touch it if the included file is newer, to make sure our timestamp dependency checking is accurate.
if (IncludedFile.LastWriteTime > WrapperFile.LastWriteTime)
{
File.SetLastWriteTimeUtc(WrapperFile.AbsolutePath, DateTime.UtcNow);
WrapperFile.ResetFileInfo();
}
return WrapperFile;
}
/// <summary>
/// Write a list of macro definitions to an output file
/// </summary>
/// <param name="Definitions">List of definitions</param>
/// <param name="Writer">Writer to receive output</param>
static void WriteDefinitions(IEnumerable<string> Definitions, TextWriter Writer)
{
foreach(string Definition in Definitions)
{
int EqualsIdx = Definition.IndexOf('=');
if(EqualsIdx == -1)
{
Writer.WriteLine("#define {0} 1", Definition);
}
else
{
Writer.WriteLine("#define {0} {1}", Definition.Substring(0, EqualsIdx), Definition.Substring(EqualsIdx + 1));
}
}
}
public static FileItem CachePCHUsageForModuleSourceFile(CppCompileEnvironment ModuleCompileEnvironment, FileItem CPPFile)
{
if (!CPPFile.bExists)
{
throw new BuildException("Required source file not found: " + CPPFile.AbsolutePath);
}
DateTime PCHCacheTimerStart = DateTime.UtcNow;
// Store the module compile environment along with the .cpp file. This is so that we can use it later on when looking
// for header dependencies
CPPFile.CachedIncludePaths = ModuleCompileEnvironment.IncludePaths;
FileItem PCHFile = ModuleCompileEnvironment.Headers.CachePCHUsageForCPPFile(CPPFile, ModuleCompileEnvironment.IncludePaths, ModuleCompileEnvironment.Platform);
if (UnrealBuildTool.bPrintPerformanceInfo)
{
double PCHCacheTime = (DateTime.UtcNow - PCHCacheTimerStart).TotalSeconds;
TotalPCHCacheTime += PCHCacheTime;
}
return PCHFile;
}
public void CachePCHUsageForModuleSourceFiles(ReadOnlyTargetRules Target, CppCompileEnvironment ModuleCompileEnvironment)
{
if(Rules == null || Rules.PCHUsage == ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs || Rules.PrivatePCHHeaderFile != null)
{
if(InvalidIncludeDirectiveMessages == null)
{
// Find all the source files in this module
List<FileReference> ModuleFiles = SourceFileSearch.FindModuleSourceFiles(RulesFile);
// Find headers used by the source file.
Dictionary<string, FileReference> NameToHeaderFile = new Dictionary<string, FileReference>();
foreach(FileReference ModuleFile in ModuleFiles)
{
if(ModuleFile.HasExtension(".h"))
{
NameToHeaderFile[ModuleFile.GetFileNameWithoutExtension()] = ModuleFile;
}
}
// Store the module compile environment along with the .cpp file. This is so that we can use it later on when looking for header dependencies
foreach (FileItem CPPFile in SourceFilesFound.CPPFiles)
{
CPPFile.CachedIncludePaths = ModuleCompileEnvironment.IncludePaths;
}
// Find the directly included files for each source file, and make sure it includes the matching header if possible
InvalidIncludeDirectiveMessages = new List<string>();
if (Rules != null && Rules.bEnforceIWYU && Target.bEnforceIWYU)
{
foreach (FileItem CPPFile in SourceFilesFound.CPPFiles)
{
List<DependencyInclude> DirectIncludeFilenames = ModuleCompileEnvironment.Headers.GetDirectIncludeDependencies(CPPFile, bOnlyCachedDependencies: false);
if (DirectIncludeFilenames.Count > 0)
{
string IncludeName = Path.GetFileNameWithoutExtension(DirectIncludeFilenames[0].IncludeName);
string ExpectedName = CPPFile.Location.GetFileNameWithoutExtension();
if (String.Compare(IncludeName, ExpectedName, StringComparison.InvariantCultureIgnoreCase) != 0)
{
FileReference HeaderFile;
if (NameToHeaderFile.TryGetValue(ExpectedName, out HeaderFile) && !IgnoreMismatchedHeader(ExpectedName))
{
InvalidIncludeDirectiveMessages.Add(String.Format("{0}(1): error: Expected {1} to be first header included.", CPPFile.Location, HeaderFile.GetFileName()));
}
}
}
}
}
}
}
else
{
if (ProcessedDependencies == null)
{
DateTime PCHCacheTimerStart = DateTime.UtcNow;
bool bFoundAProblemWithPCHs = false;
FileItem UniquePCH = null;
foreach (FileItem CPPFile in SourceFilesFound.CPPFiles) // @todo ubtmake: We're not caching CPPEnvironments for .c/.mm files, etc. Even though they don't use PCHs, they still have #includes! This can break dependency checking!
{
// Store the module compile environment along with the .cpp file. This is so that we can use it later on when looking
// for header dependencies
CPPFile.CachedIncludePaths = ModuleCompileEnvironment.IncludePaths;
// Find headers used by the source file.
FileItem PCH = ModuleCompileEnvironment.Headers.CachePCHUsageForCPPFile(CPPFile, ModuleCompileEnvironment.IncludePaths, ModuleCompileEnvironment.Platform);
if (PCH == null)
{
throw new BuildException("Source file \"{0}\" is not including any headers. We expect all modules to include a header file for precompiled header generation. Please add an #include statement.", CPPFile.AbsolutePath);
}
if (UniquePCH == null)
{
UniquePCH = PCH;
}
else if (!UniquePCH.Info.Name.Equals(PCH.Info.Name, StringComparison.InvariantCultureIgnoreCase)) // @todo ubtmake: We do a string compare on the file name (not path) here, because sometimes the include resolver will pick an Intermediate copy of a PCH header file and throw off our comparisons
{
// OK, looks like we have multiple source files including a different header file first. We'll keep track of this and print out
// helpful information afterwards.
bFoundAProblemWithPCHs = true;
}
}
ProcessedDependencies = new ProcessedDependenciesClass { UniquePCHHeaderFile = UniquePCH };
if (bFoundAProblemWithPCHs)
{
// Map from pch header string to the source files that use that PCH
Dictionary<FileReference, List<FileItem>> UsageMapPCH = new Dictionary<FileReference, List<FileItem>>();
foreach (FileItem CPPFile in SourceFilesToBuild.CPPFiles)
{
// Create a new entry if not in the pch usage map
List<FileItem> Files;
if (!UsageMapPCH.TryGetValue(CPPFile.PrecompiledHeaderIncludeFilename, out Files))
{
Files = new List<FileItem>();
UsageMapPCH.Add(CPPFile.PrecompiledHeaderIncludeFilename, Files);
}
Files.Add(CPPFile);
}
if (UnrealBuildTool.bPrintDebugInfo)
{
Log.TraceVerbose("{0} PCH files for module {1}:", UsageMapPCH.Count, Name);
int MostFilesIncluded = 0;
foreach (KeyValuePair<FileReference, List<FileItem>> CurPCH in UsageMapPCH)
{
if (CurPCH.Value.Count > MostFilesIncluded)
{
MostFilesIncluded = CurPCH.Value.Count;
}
Log.TraceVerbose(" {0} ({1} files including it: {2}, ...)", CurPCH.Key, CurPCH.Value.Count, CurPCH.Value[0].AbsolutePath);
}
}
if (UsageMapPCH.Count > 1)
{
// Keep track of the PCH file that is most used within this module
FileReference MostFilesAreIncludingPCH = null;
int MostFilesIncluded = 0;
foreach (KeyValuePair<FileReference, List<FileItem>> CurPCH in UsageMapPCH.Where(PCH => PCH.Value.Count > MostFilesIncluded))
{
MostFilesAreIncludingPCH = CurPCH.Key;
MostFilesIncluded = CurPCH.Value.Count;
}
// Find all of the files that are not including our "best" PCH header
StringBuilder FilesNotIncludingBestPCH = new StringBuilder();
foreach (KeyValuePair<FileReference, List<FileItem>> CurPCH in UsageMapPCH.Where(PCH => PCH.Key != MostFilesAreIncludingPCH))
{
foreach (FileItem SourceFile in CurPCH.Value)
{
FilesNotIncludingBestPCH.AppendFormat("{0} (including {1})\n", SourceFile.AbsolutePath, CurPCH.Key);
}
}
// Bail out and let the user know which source files may need to be fixed up
throw new BuildException(
"All source files in module \"{0}\" must include the same precompiled header first. Currently \"{1}\" is included by most of the source files. The following source files are not including \"{1}\" as their first include:\n\n{2}\n\nTo compile this module without implicit precompiled headers, add \"PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;\" to {0}.build.cs.",
Name,
MostFilesAreIncludingPCH,
FilesNotIncludingBestPCH);
}
}
if (UnrealBuildTool.bPrintPerformanceInfo)
{
double PCHCacheTime = (DateTime.UtcNow - PCHCacheTimerStart).TotalSeconds;
TotalPCHCacheTime += PCHCacheTime;
}
}
}
}
private bool IgnoreMismatchedHeader(string ExpectedName)
{
switch(ExpectedName)
{
case "Stats2":
case "DynamicRHI":
case "RHICommandList":
case "RHIUtilities":
return true;
}
switch(Name)
{
case "D3D11RHI":
case "D3D12RHI":
case "VulkanRHI":
case "OpenGLDrv":
case "MetalRHI":
case "PS4RHI":
case "Gnmx":
case "OnlineSubsystemIOS":
case "OnlineSubsystemLive":
return true;
}
return false;
}
/// <summary>
/// Determine whether optimization should be enabled for a given target
/// </summary>
/// <param name="Setting">The optimization setting from the rules file</param>
/// <param name="Configuration">The active target configuration</param>
/// <param name="bIsEngineModule">Whether the current module is an engine module</param>
/// <returns>True if optimization should be enabled</returns>
public static bool ShouldEnableOptimization(ModuleRules.CodeOptimization Setting, UnrealTargetConfiguration Configuration, bool bIsEngineModule)
{
switch(Setting)
{
case ModuleRules.CodeOptimization.Never:
return false;
case ModuleRules.CodeOptimization.Default:
case ModuleRules.CodeOptimization.InNonDebugBuilds:
return (Configuration == UnrealTargetConfiguration.Debug)? false : (Configuration != UnrealTargetConfiguration.DebugGame || bIsEngineModule);
case ModuleRules.CodeOptimization.InShippingBuildsOnly:
return (Configuration == UnrealTargetConfiguration.Shipping);
default:
return true;
}
}
/// <summary>
/// Creates a compile environment from a base environment based on the module settings.
/// </summary>
/// <param name="Target">Rules for the target being built</param>
/// <param name="BaseCompileEnvironment">An existing environment to base the module compile environment on.</param>
/// <returns>The new module compile environment.</returns>
public CppCompileEnvironment CreateModuleCompileEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment BaseCompileEnvironment)
{
CppCompileEnvironment Result = new CppCompileEnvironment(BaseCompileEnvironment);
// Override compile environment
Result.bFasterWithoutUnity = Rules.bFasterWithoutUnity;
Result.bOptimizeCode = ShouldEnableOptimization(Rules.OptimizeCode, Target.Configuration, Rules.bTreatAsEngineModule);
Result.bUseRTTI = Rules.bUseRTTI || Target.bForceEnableRTTI;
Result.bUseInlining = Target.bUseInlining;
Result.bUseAVX = Rules.bUseAVX;
Result.bEnableBufferSecurityChecks = Rules.bEnableBufferSecurityChecks;
Result.MinSourceFilesForUnityBuildOverride = Rules.MinSourceFilesForUnityBuildOverride;
Result.MinFilesUsingPrecompiledHeaderOverride = Rules.MinFilesUsingPrecompiledHeaderOverride;
Result.bBuildLocallyWithSNDBS = Rules.bBuildLocallyWithSNDBS;
Result.bEnableExceptions |= Rules.bEnableExceptions;
Result.bEnableObjCExceptions |= Rules.bEnableObjCExceptions;
Result.bEnableShadowVariableWarnings = Rules.bEnableShadowVariableWarnings;
Result.bEnableUndefinedIdentifierWarnings = Rules.bEnableUndefinedIdentifierWarnings;
Result.bUseStaticCRT = Target.bUseStaticCRT;
// Set the macro used to check whether monolithic headers can be used
if (Rules.bTreatAsEngineModule && (!Rules.bEnforceIWYU || !Target.bEnforceIWYU))
{
Result.Definitions.Add("SUPPRESS_MONOLITHIC_HEADER_WARNINGS=1");
}
// Add a macro for when we're compiling an engine module, to enable additional compiler diagnostics through code.
if (Rules.bTreatAsEngineModule)
{
Result.Definitions.Add("UE_IS_ENGINE_MODULE=1");
}
else
{
Result.Definitions.Add("UE_IS_ENGINE_MODULE=0");
}
// Switch the optimization flag if we're building a game module. Also pass the definition for building in DebugGame along (see ModuleManager.h for notes).
if (!Rules.bTreatAsEngineModule)
{
if (Target.Configuration == UnrealTargetConfiguration.DebugGame)
{
Result.Definitions.Add("UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=1");
}
else
{
Result.Definitions.Add("UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=0");
}
}
// For game modules, set the define for the project name. This will be used by the IMPLEMENT_PRIMARY_GAME_MODULE macro.
if (!Rules.bTreatAsEngineModule)
{
if (Target.ProjectFile != null)
{
string ProjectName = Target.ProjectFile.GetFileNameWithoutExtension();
Result.Definitions.Add(String.Format("UE_PROJECT_NAME={0}", ProjectName));
}
}
// Add the module's public and private definitions.
Result.Definitions.AddRange(PublicDefinitions);
Result.Definitions.AddRange(Rules.PrivateDefinitions);
// Add the project definitions
if(!Rules.bTreatAsEngineModule)
{
Result.Definitions.AddRange(Rules.Target.ProjectDefinitions);
}
// Setup the compile environment for the module.
SetupPrivateCompileEnvironment(Result.IncludePaths.UserIncludePaths, Result.IncludePaths.SystemIncludePaths, Result.Definitions, Result.AdditionalFrameworks, (Rules != null)? Rules.bLegacyPublicIncludePaths.Value : true);
// @hack to skip adding definitions to compile environment, they will be baked into source code files
if (bSkipDefinitionsForCompileEnvironment)
{
Result.Definitions.Clear();
Result.IncludePaths.UserIncludePaths = new HashSet<DirectoryReference>(BaseCompileEnvironment.IncludePaths.UserIncludePaths);
}
return Result;
}
/// <summary>
/// Creates a compile environment for a shared PCH from a base environment based on the module settings.
/// </summary>
/// <param name="Target">The target being built</param>
/// <param name="BaseCompileEnvironment">An existing environment to base the module compile environment on.</param>
/// <returns>The new shared PCH compile environment.</returns>
public CppCompileEnvironment CreateSharedPCHCompileEnvironment(UEBuildTarget Target, CppCompileEnvironment BaseCompileEnvironment)
{
CppCompileEnvironment CompileEnvironment = new CppCompileEnvironment(BaseCompileEnvironment);
// Use the default optimization setting for
CompileEnvironment.bOptimizeCode = ShouldEnableOptimization(ModuleRules.CodeOptimization.Default, Target.Configuration, Rules.bTreatAsEngineModule);
// Override compile environment
CompileEnvironment.bIsBuildingDLL = !Target.ShouldCompileMonolithic();
CompileEnvironment.bIsBuildingLibrary = false;
CompileEnvironment.bUseStaticCRT = (Target.Rules != null && Target.Rules.bUseStaticCRT);
// Add a macro for when we're compiling an engine module, to enable additional compiler diagnostics through code.
if (Rules.bTreatAsEngineModule)
{
CompileEnvironment.Definitions.Add("UE_IS_ENGINE_MODULE=1");
}
else
{
CompileEnvironment.Definitions.Add("UE_IS_ENGINE_MODULE=0");
}
// Switch the optimization flag if we're building a game module. Also pass the definition for building in DebugGame along (see ModuleManager.h for notes).
if (!Rules.bTreatAsEngineModule)
{
if (Target.Configuration == UnrealTargetConfiguration.DebugGame)
{
CompileEnvironment.Definitions.Add("UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=1");
}
else
{
CompileEnvironment.Definitions.Add("UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=0");
}
}
// Add the module's private definitions.
CompileEnvironment.Definitions.AddRange(PublicDefinitions);
// Find all the modules that are part of the public compile environment for this module.
Dictionary<UEBuildModule, bool> ModuleToIncludePathsOnlyFlag = new Dictionary<UEBuildModule, bool>();
FindModulesInPublicCompileEnvironment(ModuleToIncludePathsOnlyFlag);
// Now set up the compile environment for the modules in the original order that we encountered them
foreach (UEBuildModule Module in ModuleToIncludePathsOnlyFlag.Keys)
{
Module.AddModuleToCompileEnvironment(null, CompileEnvironment.IncludePaths.UserIncludePaths, CompileEnvironment.IncludePaths.SystemIncludePaths, CompileEnvironment.Definitions, CompileEnvironment.AdditionalFrameworks, (Rules != null)? Rules.bLegacyPublicIncludePaths.Value : true);
}
return CompileEnvironment;
}
public class UHTModuleInfoCacheType
{
public UHTModuleInfoCacheType(IEnumerable<string> InHeaderFilenames, UHTModuleInfo InInfo)
{
HeaderFilenames = InHeaderFilenames;
Info = InInfo;
}
public IEnumerable<string> HeaderFilenames = null;
public UHTModuleInfo Info = null;
}
private UHTModuleInfoCacheType UHTModuleInfoCache = null;
/// Total time spent generating PCHs for modules (not actually compiling, but generating the PCH's input data)
public static double TotalPCHGenTime = 0.0;
/// Time spent caching which PCH header is included by each module and source file
public static double TotalPCHCacheTime = 0.0;
/// <summary>
/// If any of this module's source files contain UObject definitions, this will return those header files back to the caller
/// </summary>
/// <returns></returns>
public UHTModuleInfoCacheType GetCachedUHTModuleInfo(EGeneratedCodeVersion GeneratedCodeVersion)
{
if (UHTModuleInfoCache == null)
{
List<FileReference> HeaderFiles = new List<FileReference>();
FileSystemName[] ExcludedFolders = UEBuildPlatform.GetBuildPlatform(Rules.Target.Platform, true).GetExcludedFolderNames();
FindHeaders(new DirectoryInfo(ModuleDirectory.FullName), ExcludedFolders, HeaderFiles);
UHTModuleInfo Info = ExternalExecution.CreateUHTModuleInfo(HeaderFiles, Name, RulesFile, ModuleDirectory, Type, GeneratedCodeVersion);
UHTModuleInfoCache = new UHTModuleInfoCacheType(Info.PublicUObjectHeaders.Concat(Info.PublicUObjectClassesHeaders).Concat(Info.PrivateUObjectHeaders).Select(x => x.AbsolutePath).ToList(), Info);
}
return UHTModuleInfoCache;
}
/// <summary>
/// Find all the headers under the given base directory, excluding any other platform folders.
/// </summary>
/// <param name="BaseDir">Base directory to search</param>
/// <param name="ExcludeFolders">Array of folders to exclude</param>
/// <param name="Headers">Receives the list of headers that was found</param>
static void FindHeaders(DirectoryInfo BaseDir, FileSystemName[] ExcludeFolders, List<FileReference> Headers)
{
if (!ExcludeFolders.Any(x => x.DisplayName.Equals(BaseDir.Name, StringComparison.InvariantCultureIgnoreCase)))
{
foreach (DirectoryInfo SubDir in BaseDir.EnumerateDirectories())
{
FindHeaders(SubDir, ExcludeFolders, Headers);
}
foreach (FileInfo File in BaseDir.EnumerateFiles("*.h"))
{
Headers.Add(new FileReference(File));
}
}
}
public override void GetAllDependencyModules(List<UEBuildModule> ReferencedModules, HashSet<UEBuildModule> IgnoreReferencedModules, bool bIncludeDynamicallyLoaded, bool bForceCircular, bool bOnlyDirectDependencies)
{
List<UEBuildModule> AllDependencyModules = new List<UEBuildModule>();
AllDependencyModules.AddRange(PrivateDependencyModules);
AllDependencyModules.AddRange(PublicDependencyModules);
if (bIncludeDynamicallyLoaded)
{
AllDependencyModules.AddRange(DynamicallyLoadedModules);
}
foreach (UEBuildModule DependencyModule in AllDependencyModules)
{
if (!IgnoreReferencedModules.Contains(DependencyModule))
{
// Don't follow circular back-references!
bool bIsCircular = HasCircularDependencyOn(DependencyModule.Name);
if (bForceCircular || !bIsCircular)
{
IgnoreReferencedModules.Add(DependencyModule);
if (!bOnlyDirectDependencies)
{
// Recurse into dependent modules first
DependencyModule.GetAllDependencyModules(ReferencedModules, IgnoreReferencedModules, bIncludeDynamicallyLoaded, bForceCircular, bOnlyDirectDependencies);
}
ReferencedModules.Add(DependencyModule);
}
}
}
}
public override void RecursivelyAddPrecompiledModules(List<UEBuildModule> Modules)
{
if (!Modules.Contains(this))
{
Modules.Add(this);
// Get the dependent modules
List<UEBuildModule> DependentModules = new List<UEBuildModule>();
if (PrivateDependencyModules != null)
{
DependentModules.AddRange(PrivateDependencyModules);
}
if (PublicDependencyModules != null)
{
DependentModules.AddRange(PublicDependencyModules);
}
if (DynamicallyLoadedModules != null)
{
DependentModules.AddRange(DynamicallyLoadedModules);
}
// Find modules for each of them, and add their dependencies too
foreach (UEBuildModule DependentModule in DependentModules)
{
DependentModule.RecursivelyAddPrecompiledModules(Modules);
}
}
}
}
}