/// <summary>
        /// Finds all the restricted folder names relative to a base directory
        /// </summary>
        /// <param name="BaseDir">The base directory to check against</param>
        /// <param name="OtherDir">The file or directory to check</param>
        /// <returns>Array of restricted folder names</returns>
        public static List <RestrictedFolder> FindRestrictedFolders(DirectoryReference BaseDir, DirectoryReference OtherDir)
        {
            List <RestrictedFolder> Folders = new List <RestrictedFolder>();

            if (OtherDir.IsUnderDirectory(BaseDir))
            {
                foreach (RestrictedFolder Value in RestrictedFolder.GetValues())
                {
                    string Name = Value.ToString();
                    if (OtherDir.ContainsName(Name, BaseDir.FullName.Length))
                    {
                        Folders.Add(Value);
                    }
                }
            }
            return(Folders);
        }
 /// <summary>
 /// Creates entries for all the confidential platforms. Should be called before returning any list of all folder values.
 /// </summary>
 private static void AddConfidentialPlatforms()
 {
     if (PermittedReferences == null)
     {
         Dictionary <RestrictedFolder, RestrictedFolder[]> NewPermittedReferences = new Dictionary <RestrictedFolder, RestrictedFolder[]>();
         foreach (KeyValuePair <string, DataDrivenPlatformInfo.ConfigDataDrivenPlatformInfo> Pair in DataDrivenPlatformInfo.GetAllPlatformInfos())
         {
             if (Pair.Value.bIsConfidential)
             {
                 RestrictedFolder Folder = FindOrAddByName(Pair.Key);
                 if (Pair.Value.AdditionalRestrictedFolders != null && Pair.Value.AdditionalRestrictedFolders.Length > 0)
                 {
                     RestrictedFolder[] References = Array.ConvertAll(Pair.Value.AdditionalRestrictedFolders, x => FindOrAddByName(x));
                     NewPermittedReferences[Folder] = References;
                 }
             }
         }
         PermittedReferences = NewPermittedReferences;
     }
 }
Пример #3
0
        /// <summary>
        /// Checks whether the binary output paths are appropriate for the distribution
        /// level of its direct module dependencies
        /// </summary>
        public bool CheckRestrictedFolders(List <DirectoryReference> RootDirectories, 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 = RootDirectories.FirstOrDefault(x => OutputFilePath.IsUnderDirectory(x));
                if (BaseDir == null)
                {
                    continue;
                }

                // Find the permitted restricted folder references under the base directory
                List <RestrictedFolder> BinaryFolders = RestrictedFolders.FindPermittedRestrictedFolderReferences(BaseDir, OutputFilePath.Directory);

                List <RestrictedFolder> AliasedBinaryFolders = new List <RestrictedFolder>();
                foreach (RestrictedFolder BinaryFolder in BinaryFolders)
                {
                    string Alias;
                    if (PrimaryModule.AliasRestrictedFolders.TryGetValue(BinaryFolder.ToString(), out Alias))
                    {
                        foreach (RestrictedFolder Folder in RestrictedFolder.GetValues())
                        {
                            if (Folder.ToString().Equals(Alias))
                            {
                                AliasedBinaryFolders.Add(Folder);
                            }
                        }
                    }
                }
                BinaryFolders.AddRange(AliasedBinaryFolders);

                // 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(RootDirectories);
                        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("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);
        }