[Backout] - CL22754728

[FYI] Joe.Kirchoff
Original CL Desc
-----------------------------------------------------------------
UnrealHeaderTool: BuildSetting.V3 (currently disabled) which disallows adding module parent directory to include path list

#rnx
#rb bryan.sefcik
#preflight 634df3105f008d633fd571d2

[CL 22795918 by joe kirchoff in ue5-main branch]
This commit is contained in:
joe kirchoff
2022-10-26 18:18:06 -04:00
parent 6848d0a218
commit 20c19d6503
7 changed files with 27 additions and 102 deletions

View File

@@ -1157,22 +1157,11 @@ namespace UnrealBuildTool
get { return bLegacyPublicIncludePathsPrivate ?? ((DefaultBuildSettings < BuildSettingsVersion.V2) ? Target.bLegacyPublicIncludePaths : false); }
}
private bool? bLegacyPublicIncludePathsPrivate;
/// <summary>
/// Whether this module qualifies included headers from other modules relative to the parent directory. This reduces the number
/// of search paths that have to be passed to the compiler, improving performance and reducing the length of the compiler command line.
/// </summary>
public bool bLegacyParentIncludePaths
{
set { bLegacyParentIncludePathsPrivate = value; }
get { return bLegacyParentIncludePathsPrivate ?? ((DefaultBuildSettings < BuildSettingsVersion.V3) ? Target.bLegacyParentIncludePaths : false); }
}
private bool? bLegacyParentIncludePathsPrivate;
/// <summary>
/// Whether circular dependencies will be validated against the allow list
/// Circular module dependencies result in slower builds. Disabling this option is strongly discouraged.
/// This option is ignored for Engine modules which will always be validated against the allow list.
/// This option is ignored for Engine modules which will always be validated against the allow list.
/// </summary>
public bool bValidateCircularDependencies = true;

View File

@@ -120,25 +120,16 @@ namespace UnrealBuildTool
V1,
/// <summary>
/// New defaults for 4.24:
/// * ModuleRules.PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs
/// * ModuleRules.bLegacyPublicIncludePaths = false
/// New defaults for 4.24: ModuleRules.PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs, ModuleRules.bLegacyPublicIncludePaths = false.
/// </summary>
V2,
/// <summary>
/// New defaults for 5.2:
/// * ModuleRules.bLegacyParentIncludePaths = false
/// Work in progress, not ready to be enabled as Latest.
/// </summary>
V3,
// *** When adding new entries here, be sure to update GameProjectUtils::GetDefaultBuildSettingsVersion() to ensure that new projects are created correctly. ***
/// <summary>
/// Always use the defaults for the current engine version. Note that this may cause compatibility issues when upgrading.
/// </summary>
Latest = V2,
Latest
}
/// <summary>
@@ -1861,16 +1852,6 @@ namespace UnrealBuildTool
}
private bool? bLegacyPublicIncludePathsPrivate;
/// <summary>
/// Add all the parent folders as include paths for the compile environment.
/// </summary>
public bool bLegacyParentIncludePaths
{
get { return bLegacyParentIncludePathsPrivate ?? (DefaultBuildSettings < BuildSettingsVersion.V3); }
set { bLegacyParentIncludePathsPrivate = value; }
}
private bool? bLegacyParentIncludePathsPrivate;
/// <summary>
/// Which C++ stanard to use for compiling this target
/// </summary>
@@ -2481,34 +2462,19 @@ namespace UnrealBuildTool
/// <param name="Diagnostics">List of diagnostic messages</param>
internal void GetBuildSettingsInfo(List<string> Diagnostics)
{
// Resolve BuildSettingsVersion.Latest to the version it's assigned to
BuildSettingsVersion LatestVersion = BuildSettingsVersion.Latest;
foreach (BuildSettingsVersion Value in Enum.GetValues(typeof(BuildSettingsVersion)))
{
if ((int)Value == (int)BuildSettingsVersion.Latest)
{
LatestVersion = Value;
}
}
if (DefaultBuildSettings < LatestVersion)
if(DefaultBuildSettings < BuildSettingsVersion.V2)
{
Diagnostics.Add("[Upgrade]");
Diagnostics.Add("[Upgrade] Using backward-compatible build settings. The latest version of UE sets the following values by default, which may require code changes:");
List<Tuple<string, string>> ModifiedSettings = new List<Tuple<string, string>>();
if (BuildSettingsVersion.V2 <= LatestVersion && DefaultBuildSettings < BuildSettingsVersion.V2)
if(DefaultBuildSettings < BuildSettingsVersion.V2)
{
ModifiedSettings.Add(Tuple.Create(String.Format("{0} = false", nameof(bLegacyPublicIncludePaths)), "Omits subfolders from public include paths to reduce compiler command line length. (Previously: true)."));
ModifiedSettings.Add(Tuple.Create(String.Format("{0} = WarningLevel.Error", nameof(ShadowVariableWarningLevel)), "Treats shadowed variable warnings as errors. (Previously: WarningLevel.Warning)."));
ModifiedSettings.Add(Tuple.Create(String.Format("{0} = PCHUsageMode.UseExplicitOrSharedPCHs", nameof(ModuleRules.PCHUsage)), "Set in build.cs files to enables IWYU-style PCH model. See https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/IWYU/index.html. (Previously: PCHUsageMode.UseSharedPCHs)."));
}
if (BuildSettingsVersion.V3 <= LatestVersion && DefaultBuildSettings < BuildSettingsVersion.V3)
{
ModifiedSettings.Add(Tuple.Create(String.Format("{0} = false", nameof(bLegacyParentIncludePaths)), "Omits module parent folders from include paths to reduce compiler command line length. (Previously: true)."));
}
if (ModifiedSettings.Count > 0)
{
string FormatString = String.Format("[Upgrade] {{0,-{0}}} => {{1}}", ModifiedSettings.Max(x => x.Item1.Length));
@@ -2517,7 +2483,7 @@ namespace UnrealBuildTool
Diagnostics.Add(String.Format(FormatString, ModifiedSetting.Item1, ModifiedSetting.Item2));
}
}
Diagnostics.Add(String.Format("[Upgrade] Suppress this message by setting 'DefaultBuildSettings = BuildSettingsVersion.{0};' in {1}, and explicitly overriding settings that differ from the new defaults.", LatestVersion, File!.GetFileName()));
Diagnostics.Add(String.Format("[Upgrade] Suppress this message by setting 'DefaultBuildSettings = BuildSettingsVersion.{0};' in {1}, and explicitly overriding settings that differ from the new defaults.", (BuildSettingsVersion)(BuildSettingsVersion.Latest - 1), File!.GetFileName()));
Diagnostics.Add("[Upgrade]");
}
@@ -3494,11 +3460,6 @@ namespace UnrealBuildTool
get { return Inner.bLegacyPublicIncludePaths; }
}
public bool bLegacyParentIncludePaths
{
get { return Inner.bLegacyParentIncludePaths; }
}
public CppStandardVersion CppStandard
{
get { return Inner.CppStandard; }

View File

@@ -88,11 +88,6 @@ namespace UnrealBuildTool
/// </summary>
public readonly HashSet<DirectoryReference> LegacyPublicIncludePaths = new HashSet<DirectoryReference>();
/// <summary>
/// Parent include paths which used to be added automatically, but are now only added for modules with bLegacyParentIncludePaths set.
/// </summary>
public readonly HashSet<DirectoryReference> LegacyParentIncludePaths = new HashSet<DirectoryReference>();
/// <summary>
/// Set of all private include paths
/// </summary>
@@ -566,24 +561,20 @@ namespace UnrealBuildTool
List<string> Definitions,
List<UEBuildFramework> AdditionalFrameworks,
List<FileItem> AdditionalPrerequisites,
bool bLegacyPublicIncludePaths,
bool bLegacyParentIncludePaths
bool bLegacyPublicIncludePaths
)
{
// Add this module's public include paths and definitions
// Add the module's parent directory to the include path, so we can root #includes from generated source files to it
IncludePaths.Add(ModuleDirectory.ParentDirectory!);
// Add this module's public include paths and definitions.
AddIncludePaths(IncludePaths, PublicIncludePaths);
// Add the module's parent directory to the include path, so we can root #includes from generated source files to it. Not recommended (Use BuildSetting.V3 or later)
if (bLegacyParentIncludePaths)
{
AddIncludePaths(IncludePaths, LegacyParentIncludePaths);
}
// Add this module's legacy public include paths. Not recommended (Use BuildSetting.V2 or later)
if (bLegacyPublicIncludePaths)
{
AddIncludePaths(IncludePaths, LegacyPublicIncludePaths);
}
SystemIncludePaths.UnionWith(PublicSystemIncludePaths);
Definitions.AddRange(PublicDefinitions);
// Add this module's internal include paths, only if the scope contains the same as the SourceModule's scope
if (SourceModule != null && Rules.Context.Scope.Contains(SourceModule.Rules.Context.Scope))
@@ -591,12 +582,6 @@ namespace UnrealBuildTool
AddIncludePaths(IncludePaths, InternalIncludePaths);
}
// Add this module's public system include paths
SystemIncludePaths.UnionWith(PublicSystemIncludePaths);
// Add this module's public definitions
Definitions.AddRange(PublicDefinitions);
// Add the import or export declaration for the module
if (Rules.Type == ModuleRules.ModuleType.CPlusPlus)
{
@@ -649,8 +634,7 @@ namespace UnrealBuildTool
List<string> Definitions,
List<UEBuildFramework> AdditionalFrameworks,
List<FileItem> AdditionalPrerequisites,
bool bWithLegacyPublicIncludePaths,
bool bWithLegacyParentIncludePaths
bool bWithLegacyPublicIncludePaths
)
{
if (!Rules.bTreatAsEngineModule)
@@ -669,7 +653,7 @@ namespace UnrealBuildTool
// 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(this, Binary, IncludePaths, SystemIncludePaths, ModuleInterfacePaths, Definitions, AdditionalFrameworks, AdditionalPrerequisites, bWithLegacyPublicIncludePaths, bWithLegacyParentIncludePaths);
Module.AddModuleToCompileEnvironment(this, Binary, IncludePaths, SystemIncludePaths, ModuleInterfacePaths, Definitions, AdditionalFrameworks, AdditionalPrerequisites, bWithLegacyPublicIncludePaths);
}
}

View File

@@ -270,8 +270,7 @@ namespace UnrealBuildTool
// Add the module's parent directory to the public include paths, so other modules may include headers from it explicitly.
foreach (DirectoryReference ModuleDir in ModuleDirectories)
{
// Add the parent directory to the legacy parent include paths.
LegacyParentIncludePaths.Add(ModuleDir.ParentDirectory!);
PublicIncludePaths.Add(ModuleDir.ParentDirectory!);
// Add the base directory to the legacy include paths.
LegacyPublicIncludePaths.Add(ModuleDir);
@@ -347,8 +346,7 @@ namespace UnrealBuildTool
List<string> Definitions,
List<UEBuildFramework> AdditionalFrameworks,
List<FileItem> AdditionalPrerequisites,
bool bLegacyPublicIncludePaths,
bool bLegacyParentIncludePaths
bool bLegacyPublicIncludePaths
)
{
if (GeneratedCodeDirectory != null)
@@ -370,7 +368,7 @@ namespace UnrealBuildTool
ModuleInterfacePaths.Add(UEToolChain.GetModuleInterfaceDir(IntermediateDirectory));
base.AddModuleToCompileEnvironment(SourceModule, SourceBinary, IncludePaths, SystemIncludePaths, ModuleInterfacePaths, Definitions, AdditionalFrameworks, AdditionalPrerequisites, bLegacyPublicIncludePaths, bLegacyParentIncludePaths);
base.AddModuleToCompileEnvironment(SourceModule, SourceBinary, IncludePaths, SystemIncludePaths, ModuleInterfacePaths, Definitions, AdditionalFrameworks, AdditionalPrerequisites, bLegacyPublicIncludePaths);
}
// UEBuildModule interface.
@@ -1634,7 +1632,7 @@ namespace UnrealBuildTool
}
// Setup the compile environment for the module.
SetupPrivateCompileEnvironment(Result.UserIncludePaths, Result.SystemIncludePaths, Result.ModuleInterfacePaths, Result.Definitions, Result.AdditionalFrameworks, Result.AdditionalPrerequisites, Rules.bLegacyPublicIncludePaths, Rules.bLegacyParentIncludePaths);
SetupPrivateCompileEnvironment(Result.UserIncludePaths, Result.SystemIncludePaths, Result.ModuleInterfacePaths, Result.Definitions, Result.AdditionalFrameworks, Result.AdditionalPrerequisites, Rules.bLegacyPublicIncludePaths);
return Result;
}
@@ -1687,7 +1685,7 @@ namespace UnrealBuildTool
// 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(this, null, CompileEnvironment.UserIncludePaths, CompileEnvironment.SystemIncludePaths, CompileEnvironment.ModuleInterfacePaths, CompileEnvironment.Definitions, CompileEnvironment.AdditionalFrameworks, CompileEnvironment.AdditionalPrerequisites, Rules.bLegacyPublicIncludePaths, Rules.bLegacyParentIncludePaths);
Module.AddModuleToCompileEnvironment(this, null, CompileEnvironment.UserIncludePaths, CompileEnvironment.SystemIncludePaths, CompileEnvironment.ModuleInterfacePaths, CompileEnvironment.Definitions, CompileEnvironment.AdditionalFrameworks, CompileEnvironment.AdditionalPrerequisites, Rules.bLegacyPublicIncludePaths);
}
return CompileEnvironment;
}

View File

@@ -2563,7 +2563,7 @@ namespace UnrealBuildTool
List<string> Definitions = new List<string>(GlobalCompileEnvironment.Definitions);
foreach (UEBuildModule Module in Binary.Modules)
{
Module.AddModuleToCompileEnvironment(null, null, new HashSet<DirectoryReference>(), new HashSet<DirectoryReference>(), new HashSet<DirectoryReference>(), Definitions, new List<UEBuildFramework>(), new List<FileItem>(), false, false);
Module.AddModuleToCompileEnvironment(null, null, new HashSet<DirectoryReference>(), new HashSet<DirectoryReference>(), new HashSet<DirectoryReference>(), Definitions, new List<UEBuildFramework>(), new List<FileItem>(), false);
}
// Write the header

View File

@@ -315,8 +315,7 @@ namespace UnrealBuildTool
ExportJsonStringArray(Writer, "InternalIncludePaths", Module.InternalIncludePaths.Select(x => x.FullName));
ExportJsonStringArray(Writer, "LegacyPublicIncludePaths", Module.LegacyPublicIncludePaths.Select(x => x.FullName ));
ExportJsonStringArray(Writer, "LegacyParentIncludePaths", Module.LegacyParentIncludePaths.Select(x => x.FullName));
ExportJsonStringArray(Writer, "PrivateIncludePaths", Module.PrivateIncludePaths.Select(x => x.FullName));
ExportJsonStringArray(Writer, "PublicLibraryPaths", Module.PublicSystemLibraryPaths.Select(x => x.FullName));
ExportJsonStringArray(Writer, "PublicAdditionalLibraries", Module.PublicSystemLibraries.Concat(Module.PublicLibraries.Select(x => x.FullName)));
@@ -328,9 +327,8 @@ namespace UnrealBuildTool
ExportJsonStringArray(Writer, "ProjectDefinitions", /* TODO: Add method ShouldAddProjectDefinitions */ !Module.Rules.bTreatAsEngineModule ? Module.Rules.Target.ProjectDefinitions : new string[0]);
ExportJsonStringArray(Writer, "ApiDefinitions", Module.GetEmptyApiMacros());
Writer.WriteValue("ShouldAddLegacyPublicIncludePaths", Module.Rules.bLegacyPublicIncludePaths);
Writer.WriteValue("ShouldAddLegacyParentIncludePaths", Module.Rules.bLegacyParentIncludePaths);
if (Module.Rules.CircularlyReferencedDependentModules.Any())
if(Module.Rules.CircularlyReferencedDependentModules.Any())
{
Writer.WriteArrayStart("CircularlyReferencedModules");
foreach (string ModuleName in Module.Rules.CircularlyReferencedDependentModules)

View File

@@ -22,11 +22,6 @@ namespace UnrealBuildTool
/// </summary>
const string FrameworkAssemblyExtension = ".dll";
/// <summary>
///
/// </summary>
const BuildSettingsVersion DefaultEngineBuildSettingsVersion = BuildSettingsVersion.V2;
/// <summary>
/// Find all the module rules files under a given directory
/// </summary>
@@ -155,7 +150,7 @@ namespace UnrealBuildTool
// Create the assembly
DirectoryReference AssemblyDir = RootDirectories[0];
FileReference EngineAssemblyFileName = FileReference.Combine(AssemblyDir, "Intermediate", "Build", "BuildRules", AssemblyPrefix + "Rules" + FrameworkAssemblyExtension);
RulesAssembly EngineAssembly = new RulesAssembly(Scope, RootDirectories, Plugins, ModuleFileToContext, new List<FileReference>(), EngineAssemblyFileName, bContainsEngineModules: true, DefaultBuildSettings: DefaultEngineBuildSettingsVersion, bReadOnly: bReadOnly, bSkipCompile: bSkipCompile, bForceCompile: bForceCompile, Parent: Parent, Logger: Logger);
RulesAssembly EngineAssembly = new RulesAssembly(Scope, RootDirectories, Plugins, ModuleFileToContext, new List<FileReference>(), EngineAssemblyFileName, bContainsEngineModules: true, DefaultBuildSettings: BuildSettingsVersion.Latest, bReadOnly: bReadOnly, bSkipCompile: bSkipCompile, bForceCompile: bForceCompile, Parent: Parent, Logger: Logger);
List<FileReference> ProgramTargetFiles = new List<FileReference>();
Dictionary<FileReference, ModuleRulesContext> ProgramModuleFiles = new Dictionary<FileReference, ModuleRulesContext>();
@@ -182,7 +177,7 @@ namespace UnrealBuildTool
// Create a path to the assembly that we'll either load or compile
FileReference ProgramAssemblyFileName = FileReference.Combine(AssemblyDir, "Intermediate", "Build", "BuildRules", AssemblyPrefix + "ProgramRules" + FrameworkAssemblyExtension);
RulesAssembly ProgramAssembly = new RulesAssembly(ProgramsScope, RootDirectories, new List<PluginInfo>().AsReadOnly(), ProgramModuleFiles, ProgramTargetFiles, ProgramAssemblyFileName, bContainsEngineModules: false, DefaultBuildSettings: DefaultEngineBuildSettingsVersion, bReadOnly: bReadOnly, bSkipCompile: bSkipCompile, bForceCompile: bForceCompile, Parent: EngineAssembly, Logger: Logger);
RulesAssembly ProgramAssembly = new RulesAssembly(ProgramsScope, RootDirectories, new List<PluginInfo>().AsReadOnly(), ProgramModuleFiles, ProgramTargetFiles, ProgramAssemblyFileName, bContainsEngineModules: false, DefaultBuildSettings: BuildSettingsVersion.Latest, bReadOnly: bReadOnly, bSkipCompile: bSkipCompile, bForceCompile: bForceCompile, Parent: EngineAssembly, Logger: Logger);
// Return the combined assembly
return ProgramAssembly;
@@ -215,7 +210,7 @@ namespace UnrealBuildTool
if (ModuleFileToContext.Count > 0)
{
FileReference AssemblyFileName = FileReference.Combine(UnrealBuildTool.WritableEngineDirectory, "Intermediate", "Build", "BuildRules", "MarketplaceRules.dll");
Result = new RulesAssembly(MarketplaceScope, new List<DirectoryReference> { DirectoryReference.Combine(Unreal.EngineDirectory, "Plugins", "Marketplace") }, Plugins, ModuleFileToContext, new List<FileReference>(), AssemblyFileName, bContainsEngineModules: true, DefaultBuildSettings: DefaultEngineBuildSettingsVersion, bReadOnly: bReadOnly, bSkipCompile: bSkipCompile, bForceCompile: bForceCompile, Parent: Parent, Logger: Logger);
Result = new RulesAssembly(MarketplaceScope, new List<DirectoryReference> { DirectoryReference.Combine(Unreal.EngineDirectory, "Plugins", "Marketplace") }, Plugins, ModuleFileToContext, new List<FileReference>(), AssemblyFileName, bContainsEngineModules: true, DefaultBuildSettings: BuildSettingsVersion.Latest, bReadOnly: bReadOnly, bSkipCompile: bSkipCompile, bForceCompile: bForceCompile, Parent: Parent, Logger: Logger);
}
return Result;
}