Skip to content

Instantly share code, notes, and snippets.

@ericwomer
Created May 12, 2020 12:55
Show Gist options
  • Save ericwomer/142650e65473087073f30e5fb97fd6e8 to your computer and use it in GitHub Desktop.
Save ericwomer/142650e65473087073f30e5fb97fd6e8 to your computer and use it in GitHub Desktop.
diff --git a/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildModuleCPP.cs b/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildModuleCPP.cs
index 4c0428ad373..6a6d4f71397 100644
--- a/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildModuleCPP.cs
+++ b/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildModuleCPP.cs
@@ -404,6 +404,10 @@ namespace UnrealBuildTool
// Write all the definitions to a separate file
CreateHeaderForDefinitions(CompileEnvironment, IntermediateDirectory, null, Graph);
+ if (CompileEnvironment.Definitions.Count > 0)
+ {
+ CompileEnvironment.Definitions.Clear();
+ }
// Mapping of source file to unity file. We output this to intermediate directories for other tools (eg. live coding) to use.
Dictionary<FileItem, FileItem> SourceFileToUnityFile = new Dictionary<FileItem, FileItem>();
@@ -874,6 +878,10 @@ namespace UnrealBuildTool
{
// Write all the definitions out to a separate file
CreateHeaderForDefinitions(CompileEnvironment, IntermediateDirectory, "Adaptive", Graph);
+ if (CompileEnvironment.Definitions.Count > 0)
+ {
+ CompileEnvironment.Definitions.Clear();
+ }
// Compile the files
return ToolChain.CompileCPPFiles(CompileEnvironment, Files, IntermediateDirectory, ModuleName, Graph);
@@ -886,6 +894,10 @@ namespace UnrealBuildTool
// Write all the definitions out to a separate file
CreateHeaderForDefinitions(CompileEnvironment, IntermediateDirectory, "Adaptive", Graph);
+ if (CompileEnvironment.Definitions.Count > 0)
+ {
+ CompileEnvironment.Definitions.Clear();
+ }
// Compile the files
return ToolChain.CompileCPPFiles(CompileEnvironment, Files, IntermediateDirectory, ModuleName, Graph);
@@ -1001,7 +1013,7 @@ namespace UnrealBuildTool
}
CompileEnvironment = new CppCompileEnvironment(CompileEnvironment);
- CompileEnvironment.Definitions.Clear();
+ // CompileEnvironment.Definitions.Clear(); // @todo: Do not clear definitions prior to end of their usefulness
CompileEnvironment.ForceIncludeFiles.Add(PrivateDefinitionsFileItem);
CompileEnvironment.PrecompiledHeaderAction = PrecompiledHeaderAction.Include;
CompileEnvironment.PrecompiledHeaderIncludeFilename = Instance.HeaderFile.Location;
@@ -1039,7 +1051,7 @@ namespace UnrealBuildTool
using (StringWriter Writer = new StringWriter())
{
WriteDefinitions(CompileEnvironment.Definitions, Writer);
- CompileEnvironment.Definitions.Clear();
+ //CompileEnvironment.Definitions.Clear(); @todo: Do not clear definitions prior to end of their usefulness
FileItem PrivateDefinitionsFileItem = Graph.CreateIntermediateTextFile(PrivateDefinitionsFile, Writer.ToString());
CompileEnvironment.ForceIncludeFiles.Add(PrivateDefinitionsFileItem);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment