Example #1
0
        static XmlConfigLoader()
        {
            /*
             *	There are four possible location for this file:
             *		a. UE4/Engine/Programs/UnrealBuildTool
             *		b. UE4/Engine/Programs/NotForLicensees/UnrealBuildTool
             *		c. UE4/Engine/Saved/UnrealBuildTool
             *		d. <AppData or My Documnets>/Unreal Engine/UnrealBuildTool -- the location is
             *		   chosen by existence and if both exist most recently used.
             *
             *	The UBT is looking for it in all four places in the given order and
             *	overrides already read data with the loaded ones, hence d. has the
             *	priority. Not defined classes and fields are left alone.
             */

            var UE4EnginePath = new FileInfo(Path.Combine(Utils.GetExecutingAssemblyDirectory(), "..", "..")).FullName;

            ConfigLocationHierarchy = new XmlConfigLocation[]
            {
                new XmlDefaultConfigLocation(Path.Combine(UE4EnginePath, "Programs", "UnrealBuildTool")),
                new XmlConfigLocation(Path.Combine(UE4EnginePath, "Programs", "NotForLicensees", "UnrealBuildTool"), "NotForLicensees"),
                new XmlConfigLocation(Path.Combine(UE4EnginePath, "Saved", "UnrealBuildTool"), "User", true),
                new XmlConfigLocation(new string[] {
                    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Unreal Engine", "UnrealBuildTool"),
                    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Unreal Engine", "UnrealBuildTool")
                }, "Global", true)
            };
        }
Example #2
0
        /// <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();
            }
        }
Example #3
0
 /// <summary>
 /// Gets standard BuildConfiguration.xml schema path.
 /// </summary>
 /// <returns>Standard BuildConfiguration.xml schema path.</returns>
 public static string GetXSDPath()
 {
     return(new FileInfo(Path.Combine(Utils.GetExecutingAssemblyDirectory(), "..", "..", "Saved", "UnrealBuildTool", "BuildConfiguration.Schema.xsd")).FullName);
 }