Exemple #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(ExecutingAssembly.GetDirectory(), "..", "..")).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)
            };
        }
Exemple #2
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(ExecutingAssembly.GetDirectory(), "..", "..", "Saved", "UnrealBuildTool", "BuildConfiguration.Schema.xsd")).FullName);
 }
Exemple #3
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(ExecutingAssembly.GetDirectory(), "..", "..", "..");
            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();
            }
        }
Exemple #4
0
        private static bool RequiresTempTarget(string RawProjectPath, List <UnrealTargetPlatform> ClientTargetPlatforms)
        {
            // check to see if we already have a Target.cs file
            if (File.Exists(Path.Combine(Path.GetDirectoryName(RawProjectPath), "Source", Path.GetFileNameWithoutExtension(RawProjectPath) + ".Target.cs")))
            {
                return(false);
            }
            else if (Directory.Exists(Path.Combine(Path.GetDirectoryName(RawProjectPath), "Source")))
            {
                // wasn't one in the main Source directory, let's check all sub-directories
                //@todo: may want to read each target.cs to see if it has a target corresponding to the project name as a final check
                FileInfo[] Files = (new DirectoryInfo(Path.Combine(Path.GetDirectoryName(RawProjectPath), "Source")).GetFiles("*.Target.cs", SearchOption.AllDirectories));
                if (Files.Length > 0)
                {
                    return(false);
                }
            }

            // no Target file, now check to see if build settings have changed
            List <UnrealTargetPlatform> TargetPlatforms = ClientTargetPlatforms;

            if (ClientTargetPlatforms == null || ClientTargetPlatforms.Count < 1)
            {
                // No client target platforms, add all in
                TargetPlatforms = new List <UnrealTargetPlatform>();
                foreach (UnrealTargetPlatform TargetPlatformType in Enum.GetValues(typeof(UnrealTargetPlatform)))
                {
                    if (TargetPlatformType != UnrealTargetPlatform.Unknown)
                    {
                        TargetPlatforms.Add(TargetPlatformType);
                    }
                }
            }

            // Change the working directory to be the Engine/Source folder. We are running from Engine/Binaries/DotNET
            string oldCWD = Directory.GetCurrentDirectory();

            if (BuildConfiguration.RelativeEnginePath == "../../Engine/")
            {
                string EngineSourceDirectory = Path.Combine(ExecutingAssembly.GetDirectory(), "..", "..", "..", "Engine", "Source");
                if (!Directory.Exists(EngineSourceDirectory))                 // only set the directory if it exists, this should only happen if we are launching the editor from an artist sync
                {
                    EngineSourceDirectory = Path.Combine(ExecutingAssembly.GetDirectory(), "..", "..", "..", "Engine", "Binaries");
                }
                Directory.SetCurrentDirectory(EngineSourceDirectory);
            }

            // Read the project descriptor, and find all the plugins available to this project
            ProjectDescriptor Project          = ProjectDescriptor.FromFile(RawProjectPath);
            List <PluginInfo> AvailablePlugins = Plugins.ReadAvailablePlugins(RawProjectPath);

            // check the target platforms for any differences in build settings or additional plugins
            bool RetVal = false;

            foreach (UnrealTargetPlatform TargetPlatformType in TargetPlatforms)
            {
                IUEBuildPlatform BuildPlat = UEBuildPlatform.GetBuildPlatform(TargetPlatformType, true);
                if (!GlobalCommandLine.Rocket && BuildPlat != null && !(BuildPlat as UEBuildPlatform).HasDefaultBuildConfig(TargetPlatformType, Path.GetDirectoryName(RawProjectPath)))
                {
                    RetVal = true;
                    break;
                }

                // find if there are any plugins enabled or disabled which differ from the default
                foreach (PluginInfo Plugin in AvailablePlugins)
                {
                    bool bPluginEnabledForProject = UProjectInfo.IsPluginEnabledForProject(Plugin, Project, TargetPlatformType);
                    if ((bPluginEnabledForProject && !Plugin.Descriptor.bEnabledByDefault) || (bPluginEnabledForProject && Plugin.Descriptor.bInstalled))
                    {
                        if (Plugin.Descriptor.Modules.Any(Module => Module.IsCompiledInConfiguration(TargetPlatformType, TargetRules.TargetType.Game, bBuildDeveloperTools: false, bBuildEditor: false)))
                        {
                            RetVal = true;
                            break;
                        }
                    }
                }
            }

            // Change back to the original directory
            Directory.SetCurrentDirectory(oldCWD);
            return(RetVal);
        }