/// <summary> /// Discover and fill in the project info /// </summary> public static void FillProjectInfo() { DateTime StartTime = DateTime.Now; List <string> DirectoriesToSearch = new List <string>(); // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array string RootDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetOriginalLocation()), "..", "..", ".."); string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source")); foreach (string File in Directory.EnumerateFiles(RootDirectory, "*.uprojectdirs", SearchOption.TopDirectoryOnly)) { string FilePath = Path.GetFullPath(File); Log.TraceVerbose("\tFound uprojectdirs file {0}", FilePath); using (StreamReader Reader = new StreamReader(FilePath)) { string LineRead; while ((LineRead = Reader.ReadLine()) != null) { string ProjDirEntry = LineRead.Trim(); if (String.IsNullOrEmpty(ProjDirEntry) == false) { if (ProjDirEntry.StartsWith(";")) { // Commented out line... skip it continue; } else { string DirPath = Path.GetFullPath(Path.Combine(RootDirectory, ProjDirEntry)); DirectoriesToSearch.Add(DirPath); } } } } } Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count); foreach (string DirToSearch in DirectoriesToSearch) { Log.TraceVerbose("\t\tSearching {0}", DirToSearch); if (Directory.Exists(DirToSearch)) { foreach (string SubDir in Directory.EnumerateDirectories(DirToSearch, "*", SearchOption.TopDirectoryOnly)) { Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir); string[] SubDirFiles = Directory.GetFiles(SubDir, "*.uproject", SearchOption.TopDirectoryOnly); foreach (string UProjFile in SubDirFiles) { Log.TraceVerbose("\t\t\t\t{0}", UProjFile); AddProject(new FileReference(UProjFile)); } } } else { Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch); } } DateTime StopTime = DateTime.Now; if (BuildConfiguration.bPrintPerformanceInfo) { TimeSpan TotalProjectInfoTime = StopTime - StartTime; Log.TraceInformation("FillProjectInfo took {0} milliseconds", TotalProjectInfoTime.Milliseconds); } if (UnrealBuildTool.CommandLineContains("-dumpprojectinfo")) { UProjectInfo.DumpProjectInfo(); } }
/// <summary> /// Loads JunkManifest.txt file. /// </summary> /// <returns>Junk manifest file contents.</returns> static private List <string> LoadJunkManifest() { string ManifestPath = ".." + Path.DirectorySeparatorChar + "Build" + Path.DirectorySeparatorChar + "JunkManifest.txt"; List <string> JunkManifest = new List <string>(); if (File.Exists(ManifestPath)) { string MachineName = Environment.MachineName; using (StreamReader reader = new StreamReader(ManifestPath)) { string CurrentToRootDir = ".." + Path.DirectorySeparatorChar + ".."; string LineRead; while ((LineRead = reader.ReadLine()) != null) { string JunkEntry = LineRead.Trim(); if (String.IsNullOrEmpty(JunkEntry) == false) { string[] Tokens = JunkEntry.Split(":".ToCharArray()); bool bIsValidJunkLine = true; foreach (string Token in Tokens) { if (Token.StartsWith("Machine=", StringComparison.InvariantCultureIgnoreCase) == true) { string[] InnerTokens = Token.Split("=".ToCharArray()); // check if the machine name on the line matches the current machine name, if not, we don't apply this junk if (InnerTokens.Length == 2 && MachineName.StartsWith(InnerTokens[1]) == false) { // Not meant for this machine bIsValidJunkLine = false; } } else if (Token.StartsWith("Platform=", StringComparison.InvariantCultureIgnoreCase) == true) { string[] InnerTokens = Token.Split("=".ToCharArray()); // check if the machine name on the line matches the current machine name, if not, we don't apply this junk if (InnerTokens.Length == 2) { UnrealTargetPlatform ParsedPlatform = UEBuildPlatform.ConvertStringToPlatform(InnerTokens[1]); // if the platform is valid, then we want to keep the files, which means that we don't want to apply the junk line if (ParsedPlatform != UnrealTargetPlatform.Unknown) { if (UEBuildPlatform.GetBuildPlatform(ParsedPlatform, bInAllowFailure: true) != null) { // this is a good platform, so don't delete any files! bIsValidJunkLine = false; } } } } } // All paths within the manifest are UE4 root directory relative. // UBT's working directory is Engine\Source so add "..\..\" to each of the entires. if (bIsValidJunkLine) { // the entry is always the last element in the token array (after the final :) string FixedPath = Path.Combine(CurrentToRootDir, Tokens[Tokens.Length - 1]); FixedPath = FixedPath.Replace('\\', Path.DirectorySeparatorChar); JunkManifest.Add(FixedPath); } } } } } return(JunkManifest); }
/// <summary> /// Discover and fill in the project info /// </summary> public static void FillProjectInfo() { DateTime StartTime = DateTime.Now; List <string> DirectoriesToSearch = new List <string>(); // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array string RootDirectory = Path.Combine(Utils.GetExecutingAssemblyDirectory(), "..", "..", ".."); string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source")); foreach (var File in Directory.EnumerateFiles(RootDirectory, "*.uprojectdirs", SearchOption.TopDirectoryOnly)) { string FilePath = Path.GetFullPath(File); Log.TraceVerbose("\tFound uprojectdirs file {0}", FilePath); using (StreamReader Reader = new StreamReader(FilePath)) { string LineRead; while ((LineRead = Reader.ReadLine()) != null) { string ProjDirEntry = LineRead.Trim(); if (String.IsNullOrEmpty(ProjDirEntry) == false) { if (ProjDirEntry.StartsWith(";")) { // Commented out line... skip it continue; } else { string DirPath = Path.GetFullPath(Path.Combine(RootDirectory, ProjDirEntry)); DirectoriesToSearch.Add(DirPath); } } } } } Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count); // Initialize the target finding time to 0 TimeSpan TotalTargetTime = DateTime.Now - DateTime.Now; foreach (string DirToSearch in DirectoriesToSearch) { Log.TraceVerbose("\t\tSearching {0}", DirToSearch); if (Directory.Exists(DirToSearch)) { foreach (string SubDir in Directory.EnumerateDirectories(DirToSearch, "*", SearchOption.TopDirectoryOnly)) { Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir); string[] SubDirFiles = Directory.GetFiles(SubDir, "*.uproject", SearchOption.TopDirectoryOnly); foreach (string UProjFile in SubDirFiles) { string RelativePath = Utils.MakePathRelativeTo(UProjFile, EngineSourceDirectory); Log.TraceVerbose("\t\t\t\t{0}", RelativePath); if (!ProjectInfoDictionary.ContainsKey(RelativePath)) { DateTime TargetStartTime = DateTime.Now; string SourceFolder = Path.Combine(Path.GetDirectoryName(UProjFile), "Source"); bool bIsCodeProject = Directory.Exists(SourceFolder); AddProject(RelativePath, bIsCodeProject); if (bIsCodeProject) { // Find all Target.cs files bool bFoundTargetFiles = false; if (!FindTargetFiles(SourceFolder, ref bFoundTargetFiles)) { Log.TraceVerbose("No target files found under " + SourceFolder); } } DateTime TargetStopTime = DateTime.Now; TotalTargetTime += TargetStopTime - TargetStartTime; } } } } else { Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch); } } DateTime StopTime = DateTime.Now; if (BuildConfiguration.bPrintPerformanceInfo) { TimeSpan TotalProjectInfoTime = StopTime - StartTime; Log.TraceInformation("FillProjectInfo took {0} milliseconds (AddTargetInfo {1} ms)", TotalProjectInfoTime.Milliseconds, TotalTargetTime.Milliseconds); } if (UnrealBuildTool.CommandLineContains("-dumpprojectinfo")) { UProjectInfo.DumpProjectInfo(); } }