/// <summary> /// Checks whether the binary output paths are appropriate for the distribution /// level of its direct module dependencies /// </summary> public bool CheckRestrictedFolders(DirectoryReference ProjectDir, Dictionary <UEBuildModule, Dictionary <RestrictedFolder, DirectoryReference> > ModuleRestrictedFolderCache) { // Find all the modules we depend on Dictionary <UEBuildModule, UEBuildModule> ModuleReferencedBy = new Dictionary <UEBuildModule, UEBuildModule>(); FindModuleReferences(ModuleReferencedBy); // Loop through each of the output binaries and check them separately bool bResult = true; foreach (FileReference OutputFilePath in OutputFilePaths) { // Find the base directory for this binary DirectoryReference BaseDir; if (OutputFilePath.IsUnderDirectory(UnrealBuildTool.EngineDirectory)) { BaseDir = UnrealBuildTool.EngineDirectory; } else if (ProjectDir != null && OutputFilePath.IsUnderDirectory(ProjectDir)) { BaseDir = ProjectDir; } else { continue; } // Find the restricted folders under the base directory List <RestrictedFolder> BinaryFolders = RestrictedFolders.FindRestrictedFolders(BaseDir, OutputFilePath.Directory); // Check all the dependent modules foreach (UEBuildModule Module in ModuleReferencedBy.Keys) { // Find the restricted folders for this module Dictionary <RestrictedFolder, DirectoryReference> ModuleRestrictedFolders; if (!ModuleRestrictedFolderCache.TryGetValue(Module, out ModuleRestrictedFolders)) { ModuleRestrictedFolders = Module.FindRestrictedFolderReferences(ProjectDir); ModuleRestrictedFolderCache.Add(Module, ModuleRestrictedFolders); } // Write errors for any missing paths in the output files foreach (KeyValuePair <RestrictedFolder, DirectoryReference> Pair in ModuleRestrictedFolders) { if (!BinaryFolders.Contains(Pair.Key)) { List <string> ReferenceChain = new List <string>(); for (UEBuildModule ReferencedModule = Module; ReferencedModule != null; ReferencedModule = ModuleReferencedBy[ReferencedModule]) { ReferenceChain.Insert(0, ReferencedModule.Name); } Log.TraceError("ERROR: Output binary \"{0}\" is not in a {1} folder, but references \"{2}\" via {3}.", OutputFilePath, Pair.Key.ToString(), Pair.Value, String.Join(" -> ", ReferenceChain)); bResult = false; } } } } return(bResult); }
/// <summary> /// Determines the distribution level of a module based on its directory and includes. /// </summary> /// <param name="ProjectDir">The project directory, if available</param> /// <returns>Map of the restricted folder types to the first found instance</returns> public Dictionary <RestrictedFolder, DirectoryReference> FindRestrictedFolderReferences(DirectoryReference ProjectDir) { Dictionary <RestrictedFolder, DirectoryReference> References = new Dictionary <RestrictedFolder, DirectoryReference>(); if (!Rules.bOutputPubliclyDistributable) { // Find all the directories that this module references HashSet <DirectoryReference> ReferencedDirs = new HashSet <DirectoryReference>(); GetReferencedDirectories(ReferencedDirs); if (Name == "WinDualShock") { Console.Write(""); } // Remove all the whitelisted folders ReferencedDirs.ExceptWith(WhitelistRestrictedFolders); ReferencedDirs.ExceptWith(PublicDependencyModules.SelectMany(x => x.WhitelistRestrictedFolders)); ReferencedDirs.ExceptWith(PrivateDependencyModules.SelectMany(x => x.WhitelistRestrictedFolders)); // Add flags for each of them foreach (DirectoryReference ReferencedDir in ReferencedDirs) { // Find the base directory containing this reference DirectoryReference BaseDir; if (ReferencedDir.IsUnderDirectory(UnrealBuildTool.EngineDirectory)) { BaseDir = UnrealBuildTool.EngineDirectory; } else if (ProjectDir != null && ReferencedDir.IsUnderDirectory(ProjectDir)) { BaseDir = ProjectDir; } else { continue; } // Add references to each of the restricted folders List <RestrictedFolder> Folders = RestrictedFolders.FindRestrictedFolders(BaseDir, ReferencedDir); foreach (RestrictedFolder Folder in Folders) { if (!References.ContainsKey(Folder)) { References.Add(Folder, ReferencedDir); } } } } return(References); }
/// <summary> /// Determines the distribution level of a module based on its directory and includes. /// </summary> /// <param name="ProjectDir">The project directory, if available</param> /// <returns>Map of the restricted folder types to the first found instance</returns> public Dictionary <RestrictedFolder, DirectoryReference> FindRestrictedFolderReferences(DirectoryReference ProjectDir) { Dictionary <RestrictedFolder, DirectoryReference> References = new Dictionary <RestrictedFolder, DirectoryReference>(); if (!Rules.bLegalToDistributeObjectCode) { // Find all the directories that this module references HashSet <DirectoryReference> ReferencedDirs = new HashSet <DirectoryReference>(); GetReferencedDirectories(ReferencedDirs); // Remove all the whitelisted folders ReferencedDirs.ExceptWith(WhitelistRestrictedFolders); ReferencedDirs.ExceptWith(PublicDependencyModules.SelectMany(x => x.WhitelistRestrictedFolders)); ReferencedDirs.ExceptWith(PrivateDependencyModules.SelectMany(x => x.WhitelistRestrictedFolders)); // Add flags for each of them foreach (DirectoryReference ReferencedDir in ReferencedDirs) { // Find the base directory containing this reference DirectoryReference BaseDir; // @todo platplug does this need to check platform extension engine directories? what are ReferencedDir's here? if (ReferencedDir.IsUnderDirectory(UnrealBuildTool.EngineDirectory)) { BaseDir = UnrealBuildTool.EngineDirectory; } else if (ProjectDir != null && ReferencedDir.IsUnderDirectory(ProjectDir)) { BaseDir = ProjectDir; } else { continue; } // Add references to each of the restricted folders List <RestrictedFolder> Folders = RestrictedFolders.FindRestrictedFolders(BaseDir, ReferencedDir); foreach (RestrictedFolder Folder in Folders) { if (!References.ContainsKey(Folder)) { References.Add(Folder, ReferencedDir); } } } } return(References); }