Exemple #1
0
 private void CacheDirectories()
 {
     if (Directories == null)
     {
         Directories = new HashSet <DirectoryReference>(DirectoryReference.EnumerateDirectories(Location));
     }
 }
Exemple #2
0
        static void FindFilesInternalRecursive(DirectoryReference Directory, string[] ExcludedDirectorySuffixes, List <FileReference> FoundFiles, HashSet <DirectoryReference> SearchedDirectories)
        {
            FindFilesInternal(Directory, ExcludedDirectorySuffixes, FoundFiles, SearchedDirectories);

            foreach (DirectoryReference SubDirectory in DirectoryReference.EnumerateDirectories(Directory))
            {
                if (ShouldInclude(SubDirectory, ExcludedDirectorySuffixes))
                {
                    FindFilesInternalRecursive(SubDirectory, ExcludedDirectorySuffixes, FoundFiles, SearchedDirectories);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Finds all the extension directories for the given base directory. This includes platform extensions and restricted folders.
        /// </summary>
        /// <param name="BaseDir">Location of the base directory</param>
        /// <param name="bIncludePlatformDirectories">If true, platform subdirectories are included (will return platform directories under Restricted dirs, even if bIncludeRestrictedDirectories is false)</param>
        /// <param name="bIncludeRestrictedDirectories">If true, restricted (NotForLicensees, NoRedist) subdirectories are included</param>
        /// <param name="bIncludeBaseDirectory">If true, BaseDir is included</param>
        /// <returns>List of extension directories, including the given base directory</returns>
        public static List <DirectoryReference> GetExtensionDirs(DirectoryReference BaseDir, bool bIncludePlatformDirectories = true, bool bIncludeRestrictedDirectories = true, bool bIncludeBaseDirectory = true)
        {
            Tuple <List <DirectoryReference>, List <DirectoryReference> > CachedDirs;

            if (!CachedExtensionDirectories.TryGetValue(BaseDir, out CachedDirs))
            {
                CachedDirs = Tuple.Create(new List <DirectoryReference>(), new List <DirectoryReference>());

                CachedExtensionDirectories[BaseDir] = CachedDirs;

                DirectoryReference PlatformExtensionBaseDir = DirectoryReference.Combine(BaseDir, "Platforms");
                if (DirectoryReference.Exists(PlatformExtensionBaseDir))
                {
                    CachedDirs.Item1.AddRange(DirectoryReference.EnumerateDirectories(PlatformExtensionBaseDir));
                }

                DirectoryReference RestrictedBaseDir = DirectoryReference.Combine(BaseDir, "Restricted");
                if (DirectoryReference.Exists(RestrictedBaseDir))
                {
                    IEnumerable <DirectoryReference> RestrictedDirs = DirectoryReference.EnumerateDirectories(RestrictedBaseDir);
                    CachedDirs.Item2.AddRange(RestrictedDirs);

                    // also look for nested platforms in the restricted
                    foreach (DirectoryReference RestrictedDir in RestrictedDirs)
                    {
                        DirectoryReference RestrictedPlatformExtensionBaseDir = DirectoryReference.Combine(RestrictedDir, "Platforms");
                        if (DirectoryReference.Exists(RestrictedPlatformExtensionBaseDir))
                        {
                            CachedDirs.Item1.AddRange(DirectoryReference.EnumerateDirectories(RestrictedPlatformExtensionBaseDir));
                        }
                    }
                }
            }

            // now return what the caller wanted (always include BaseDir)
            List <DirectoryReference> ExtensionDirs = new List <DirectoryReference>();

            if (bIncludeBaseDirectory)
            {
                ExtensionDirs.Add(BaseDir);
            }
            if (bIncludePlatformDirectories)
            {
                ExtensionDirs.AddRange(CachedDirs.Item1);
            }
            if (bIncludeRestrictedDirectories)
            {
                ExtensionDirs.AddRange(CachedDirs.Item2);
            }
            return(ExtensionDirs);
        }
Exemple #4
0
 /// <summary>
 /// Find paths to all the plugins under a given parent directory (recursively)
 /// </summary>
 /// <param name="ParentDirectory">Parent directory to look in. Plugins will be found in any *subfolders* of this directory.</param>
 /// <param name="FileNames">List of filenames. Will have all the discovered .uplugin files appended to it.</param>
 static void EnumeratePluginsInternal(DirectoryReference ParentDirectory, List <FileReference> FileNames)
 {
     foreach (DirectoryReference ChildDirectory in DirectoryReference.EnumerateDirectories(ParentDirectory))
     {
         int InitialFileNamesCount = FileNames.Count;
         foreach (FileReference PluginFile in DirectoryReference.EnumerateFiles(ChildDirectory, "*.uplugin"))
         {
             FileNames.Add(PluginFile);
         }
         if (FileNames.Count == InitialFileNamesCount)
         {
             EnumeratePluginsInternal(ChildDirectory, FileNames);
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// The main engine directory and all found platform extension engine directories
        /// </summary>
        public static DirectoryReference[] GetAllEngineDirectories(string Suffix = "")
        {
            List <DirectoryReference> EngineDirectories = new List <DirectoryReference>()
            {
                DirectoryReference.Combine(EngineDirectory, Suffix)
            };

            if (DirectoryReference.Exists(PlatformExtensionsDirectory))
            {
                foreach (DirectoryReference PlatformDirectory in DirectoryReference.EnumerateDirectories(PlatformExtensionsDirectory))
                {
                    DirectoryReference PlatformEngineDirectory = DirectoryReference.Combine(PlatformDirectory, "Engine", Suffix);
                    if (DirectoryReference.Exists(PlatformEngineDirectory))
                    {
                        EngineDirectories.Add(PlatformEngineDirectory);
                    }
                }
            }
            return(EngineDirectories.ToArray());
        }
Exemple #6
0
        /// <summary>
        /// Returns the main project directory and all found platform extension project directories, with
        /// an optional subdirectory to look for within each location (ie, "Config" or "Source/Runtime")
        /// </summary>
        /// <param name="ProjectDirectory">Location of the project on disk</param>
        /// <param name="Suffix">Optional subdirectory to look in for each location</param>
        /// <returns>the main project directory and all found platform extension project directories</returns>
        public static DirectoryReference[] GetAllProjectDirectories(DirectoryReference ProjectDirectory, string Suffix = "")
        {
            List <DirectoryReference> ProjectDirectories = new List <DirectoryReference>()
            {
                DirectoryReference.Combine(ProjectDirectory, Suffix)
            };

            if (DirectoryReference.Exists(ProjectPlatformExtensionsDirectory(ProjectDirectory)))
            {
                foreach (DirectoryReference PlatformDirectory in DirectoryReference.EnumerateDirectories(ProjectPlatformExtensionsDirectory(ProjectDirectory), "*", SearchOption.TopDirectoryOnly))
                {
                    DirectoryReference PlatformEngineDirectory = DirectoryReference.Combine(PlatformDirectory, Suffix);
                    if (DirectoryReference.Exists(PlatformEngineDirectory))
                    {
                        ProjectDirectories.Add(PlatformEngineDirectory);
                    }
                }
            }
            return(ProjectDirectories.ToArray());
        }
Exemple #7
0
        /// <summary>
        /// The main project directory and all found platform extension project directories
        /// </summary>
        public static DirectoryReference[] GetAllProjectDirectories(FileReference ProjectFile, string Suffix = "")
        {
            // project name may not match the directory name, so use the ProjectFile's name as ProjectName
            string ProjectName = ProjectFile.GetFileNameWithoutAnyExtensions();

            List <DirectoryReference> ProjectDirectories = new List <DirectoryReference>()
            {
                DirectoryReference.Combine(ProjectFile.Directory, Suffix)
            };

            if (DirectoryReference.Exists(PlatformExtensionsDirectory))
            {
                foreach (DirectoryReference PlatformDirectory in DirectoryReference.EnumerateDirectories(PlatformExtensionsDirectory))
                {
                    DirectoryReference PlatformEngineDirectory = DirectoryReference.Combine(PlatformDirectory, ProjectName, Suffix);
                    if (DirectoryReference.Exists(PlatformEngineDirectory))
                    {
                        ProjectDirectories.Add(PlatformEngineDirectory);
                    }
                }
            }
            return(ProjectDirectories.ToArray());
        }
Exemple #8
0
 /// <summary>
 /// Searches a directory tree for build products to be cleaned.
 /// </summary>
 /// <param name="BaseDir">The directory to search</param>
 /// <param name="NamePrefixes">Target or application names that may appear at the start of the build product name (eg. "UE4Editor", "ShooterGameEditor")</param>
 /// <param name="NameSuffixes">Suffixes which may appear at the end of the build product name</param>
 /// <param name="FilesToClean">List to receive a list of files to be cleaned</param>
 /// <param name="DirectoriesToClean">List to receive a list of directories to be cleaned</param>
 public void FindBuildProductsToClean(DirectoryReference BaseDir, string[] NamePrefixes, string[] NameSuffixes, List <FileReference> FilesToClean, List <DirectoryReference> DirectoriesToClean)
 {
     foreach (FileReference File in DirectoryReference.EnumerateFiles(BaseDir))
     {
         string FileName = File.GetFileName();
         if (IsDefaultBuildProduct(FileName, NamePrefixes, NameSuffixes) || IsBuildProduct(FileName, NamePrefixes, NameSuffixes))
         {
             FilesToClean.Add(File);
         }
     }
     foreach (DirectoryReference SubDir in DirectoryReference.EnumerateDirectories(BaseDir))
     {
         string SubDirName = SubDir.GetDirectoryName();
         if (IsBuildProduct(SubDirName, NamePrefixes, NameSuffixes))
         {
             DirectoriesToClean.Add(SubDir);
         }
         else
         {
             FindBuildProductsToClean(SubDir, NamePrefixes, NameSuffixes, FilesToClean, DirectoriesToClean);
         }
     }
 }
Exemple #9
0
        /// <summary>
        /// Discover and fill in the project info
        /// </summary>
        public static void FillProjectInfo()
        {
            DateTime StartTime = DateTime.Now;

            List <DirectoryReference> DirectoriesToSearch = new List <DirectoryReference>();

            // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array
            string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source"));

            foreach (FileReference ProjectDirsFile in DirectoryReference.EnumerateFiles(UnrealBuildTool.RootDirectory, "*.uprojectdirs", SearchOption.TopDirectoryOnly))
            {
                Log.TraceVerbose("\tFound uprojectdirs file {0}", ProjectDirsFile.FullName);
                foreach (string Line in File.ReadAllLines(ProjectDirsFile.FullName))
                {
                    string TrimLine = Line.Trim();
                    if (!TrimLine.StartsWith(";"))
                    {
                        DirectoryReference BaseProjectDir = DirectoryReference.Combine(UnrealBuildTool.RootDirectory, TrimLine);
                        if (BaseProjectDir.IsUnderDirectory(UnrealBuildTool.RootDirectory))
                        {
                            DirectoriesToSearch.Add(BaseProjectDir);
                        }
                        else
                        {
                            Log.TraceWarning("Project search path '{0}' is not under root directory, ignoring.", TrimLine);
                        }
                    }
                }
            }

            Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count);

            foreach (DirectoryReference DirToSearch in DirectoriesToSearch)
            {
                Log.TraceVerbose("\t\tSearching {0}", DirToSearch.FullName);
                if (DirectoryReference.Exists(DirToSearch))
                {
                    foreach (DirectoryReference SubDir in DirectoryReference.EnumerateDirectories(DirToSearch, "*", SearchOption.TopDirectoryOnly))
                    {
                        Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir.FullName);
                        foreach (FileReference UProjFile in DirectoryReference.EnumerateFiles(SubDir, "*.uproject", SearchOption.TopDirectoryOnly))
                        {
                            Log.TraceVerbose("\t\t\t\t{0}", UProjFile.FullName);
                            AddProject(UProjFile);
                        }
                    }
                }
                else
                {
                    Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch);
                }
            }

            DateTime StopTime = DateTime.Now;

            if (UnrealBuildTool.bPrintPerformanceInfo)
            {
                TimeSpan TotalProjectInfoTime = StopTime - StartTime;
                Log.TraceInformation("FillProjectInfo took {0} milliseconds", TotalProjectInfoTime.TotalMilliseconds);
            }
        }
Exemple #10
0
        /// <summary>
        /// Read all the plugin descriptors under the given directory
        /// </summary>
        /// <param name="RootDirectory">The directory to look in.</param>
        /// <param name="Subdirectory">A subdirectory to look in in RootDirectory and any other Platform directories under Root</param>
        /// <param name="Type">The plugin type</param>
        /// <returns>Sequence of the found PluginInfo object.</returns>
        public static IReadOnlyList <PluginInfo> ReadPluginsFromDirectory(DirectoryReference RootDirectory, string Subdirectory, PluginType Type)
        {
            // look for directories in RootDirectory and and Platform directories under RootDirectory
            List <DirectoryReference> RootDirectories = new List <DirectoryReference>()
            {
                DirectoryReference.Combine(RootDirectory, Subdirectory)
            };

            // now look for platform subdirectories with the Subdirectory
            DirectoryReference PlatformDirectory = DirectoryReference.Combine(RootDirectory, "Platforms");

            if (DirectoryReference.Exists(PlatformDirectory))
            {
                foreach (DirectoryReference Dir in DirectoryReference.EnumerateDirectories(PlatformDirectory))
                {
                    RootDirectories.Add(DirectoryReference.Combine(Dir, Subdirectory));
                }
            }

            Dictionary <PluginInfo, FileReference> ChildPlugins = new Dictionary <PluginInfo, FileReference>();
            List <PluginInfo> AllParentPlugins = new List <PluginInfo>();

            foreach (DirectoryReference Dir in RootDirectories)
            {
                if (!DirectoryReference.Exists(Dir))
                {
                    continue;
                }

                List <PluginInfo> Plugins;
                if (!PluginInfoCache.TryGetValue(Dir, out Plugins))
                {
                    Plugins = new List <PluginInfo>();
                    foreach (FileReference PluginFileName in EnumeratePlugins(Dir))
                    {
                        PluginInfo Plugin = new PluginInfo(PluginFileName, Type);

                        // is there a parent to merge up into?
                        if (Plugin.Descriptor.bIsPluginExtension)
                        {
                            ChildPlugins.Add(Plugin, PluginFileName);
                        }
                        else
                        {
                            Plugins.Add(Plugin);
                        }
                    }
                    PluginInfoCache.Add(Dir, Plugins);
                }

                // gather all of the plugins into one list
                AllParentPlugins.AddRange(Plugins);
            }

            // now that all parent plugins are read in, we can let the children look up the parents
            foreach (KeyValuePair <PluginInfo, FileReference> Pair in ChildPlugins)
            {
                TryMergeWithParent(Pair.Key, Pair.Value);
            }

            return(AllParentPlugins);
        }