/// <summary>
 /// Returns the ConfigDataDrivenPlatformInfo for the given platform, or null if nothing was found
 /// </summary>
 public static string GetIniPlatformParentName(string IniPlatformName)
 {
     DataDrivenPlatformInfo.ConfigDataDrivenPlatformInfo Info = DataDrivenPlatformInfo.GetDataDrivenInfoForPlatform(IniPlatformName);
     return((Info == null) ? "" : Info.IniParent);
 }
Beispiel #2
0
        /// <summary>
        /// Returns a list of INI filenames for the given project
        /// </summary>
        public static IEnumerable <FileReference> EnumerateConfigFileLocations(ConfigHierarchyType Type, DirectoryReference ProjectDir, UnrealTargetPlatform Platform)
        {
            string BaseIniName  = Enum.GetName(typeof(ConfigHierarchyType), Type);
            string PlatformName = GetIniPlatformName(Platform);

            foreach (ConfigLayer Layer in ConfigLayers)
            {
                bool   bHasPlatformTag, bHasProjectTag, bHasExpansionTag;
                string LayerPath = GetLayerPath(Layer, Platform.ToString(), PlatformName, ProjectDir, BaseIniName, out bHasPlatformTag, out bHasProjectTag, out bHasExpansionTag);

                // skip the layer if we aren't going to use it
                if (LayerPath == null)
                {
                    continue;
                }

                // handle expansion (and platform - the C++ code will validate that only expansion layers have platforms)
                if (bHasExpansionTag)
                {
                    foreach (ConfigLayerExpansion Expansion in ConfigLayerExpansions)
                    {
                        // expansion replacements
                        string ExpansionPath = GetExpansionPath(Expansion, LayerPath);

                        // now go up the ini parent chain
                        if (bHasPlatformTag)
                        {
                            DataDrivenPlatformInfo.ConfigDataDrivenPlatformInfo Info = DataDrivenPlatformInfo.GetDataDrivenInfoForPlatform(PlatformName);
                            if (Info != null && Info.IniParentChain != null)
                            {
                                // the IniParentChain
                                foreach (string ParentPlatform in Info.IniParentChain)
                                {
                                    // @note: We are using the ParentPlatform as both PlatformExtensionName _and_ IniPlatformName. This is because the parent
                                    // may not even exist as a UnrealTargetPlatform, and all we have is a string to look up, and it would just get the same
                                    // string back, if we did look it up. This could become an issue if Win64 becomes a PlatformExtension, and wants to have
                                    // a parent Platform, of ... something. This is likely to never be an issue, but leaving this note here just in case.
                                    string LocalLayerPath     = GetLayerPath(Layer, ParentPlatform, ParentPlatform, ProjectDir, BaseIniName, out bHasPlatformTag, out bHasProjectTag, out bHasExpansionTag);
                                    string LocalExpansionPath = GetExpansionPath(Expansion, LocalLayerPath);
                                    yield return(new FileReference(LocalExpansionPath.Replace("{PLATFORM}", ParentPlatform)));
                                }
                            }
                            // always yield the active platform last
                            yield return(new FileReference(ExpansionPath.Replace("{PLATFORM}", PlatformName)));
                        }
                        else
                        {
                            yield return(new FileReference(ExpansionPath));
                        }
                    }
                }
                else
                {
                    yield return(new FileReference(LayerPath));
                }
            }

            // Find all the generated config files
            foreach (FileReference GeneratedConfigFile in EnumerateGeneratedConfigFileLocations(Type, ProjectDir, Platform))
            {
                yield return(GeneratedConfigFile);
            }
        }
Beispiel #3
0
		/// <summary>
		/// Returns a list of INI filenames for the given project
		/// </summary>
		public static IEnumerable<FileReference> EnumerateConfigFileLocations(ConfigHierarchyType Type, DirectoryReference ProjectDir, UnrealTargetPlatform Platform)
		{
			string BaseIniName = Enum.GetName(typeof(ConfigHierarchyType), Type);
			string PlatformName = GetIniPlatformName(Platform);

			// cache some platform extension information that can be used inside the loops
			string PlatformExtensionEngineConfigDir = DirectoryReference.Combine(UnrealBuildTool.PlatformExtensionsDirectory, Platform.ToString(), "Engine").FullName;
			string PlatformExtensionProjectConfigDir = ProjectDir != null ? DirectoryReference.Combine(UnrealBuildTool.PlatformExtensionsDirectory, Platform.ToString(), ProjectDir.GetDirectoryName()).FullName : null;
			bool bHasPlatformExtensionEngineConfigDir = Directory.Exists(PlatformExtensionEngineConfigDir);
			bool bHasPlatformExtensionProjectConfigDir = PlatformExtensionProjectConfigDir != null && Directory.Exists(PlatformExtensionProjectConfigDir);


			foreach (ConfigLayer Layer in ConfigLayers)
			{
				bool bHasPlatformTag = Layer.Path.Contains("{PLATFORM}");
				bool bHasProjectTag = Layer.Path.Contains("{PROJECT}");
				bool bHasExpansionTag = Layer.Path.Contains("{ED}") || Layer.Path.Contains("{EF}");
				bool bHasUserTag = Layer.Path.Contains("{USER}");

				// skip platform layers if we are "platform-less", or user layers without a user dir
				if (bHasPlatformTag && Platform == null ||
					bHasProjectTag && ProjectDir == null ||
					bHasUserTag && GetUserDir() == null)
				{
					continue;
				}

				// basic replacements
				string LayerPath;
				// you can only have PROJECT or ENGINE, not both
				if (bHasProjectTag)
				{
					if (bHasPlatformTag && bHasPlatformExtensionProjectConfigDir)
					{
						LayerPath = Layer.ExtProjectPath.Replace("{EXTPROJECT}", PlatformExtensionProjectConfigDir);
					}
					else
					{
						LayerPath = Layer.Path.Replace("{PROJECT}", ProjectDir.FullName);
					}
				}
				else
				{
					if (bHasPlatformTag && bHasPlatformExtensionEngineConfigDir)
					{
						LayerPath = Layer.ExtEnginePath.Replace("{EXTENGINE}", PlatformExtensionEngineConfigDir);
					}
					else
					{
						LayerPath = Layer.Path.Replace("{ENGINE}", UnrealBuildTool.EngineDirectory.FullName);
					}
				}
				LayerPath = LayerPath.Replace("{TYPE}", BaseIniName);
				LayerPath = LayerPath.Replace("{USERSETTINGS}", Utils.GetUserSettingDirectory().FullName);
				if (bHasUserTag) LayerPath = LayerPath.Replace("{USER}", GetUserDir());


				// handle expansion (and platform - the C++ code will validate that only expansion layers have platforms)
				if (bHasExpansionTag)
				{
					foreach (ConfigLayerExpansion Expansion in ConfigLayerExpansions)
					{
						// expansion replacements
						string ExpansionPath = LayerPath.Replace("{ED}", Expansion.DirectoryPrefix);
						ExpansionPath = ExpansionPath.Replace("{EF}", Expansion.FilePrefix);

						// now go up the ini parent chain
						if (bHasPlatformTag)
						{
							DataDrivenPlatformInfo.ConfigDataDrivenPlatformInfo Info = DataDrivenPlatformInfo.GetDataDrivenInfoForPlatform(PlatformName);
							if (Info != null && Info.IniParentChain != null)
							{
								// the IniParentChain
								foreach (string ParentPlatform in Info.IniParentChain)
								{
									yield return new FileReference(ExpansionPath.Replace("{PLATFORM}", ParentPlatform));
								}
							}
							// always yield the active platform last 
							yield return new FileReference(ExpansionPath.Replace("{PLATFORM}", PlatformName));
						}
						else
						{
							yield return new FileReference(ExpansionPath);
						}
					}
				}
				else
				{
					yield return new FileReference(LayerPath);
				}
			}

			// Get the generated config file too. EditorSettings overrides this from 
			if(Type == ConfigHierarchyType.EditorSettings)
			{
				yield return FileReference.Combine(GetGameAgnosticSavedDir(), "Config", PlatformName, BaseIniName + ".ini");
			}
			else
			{
				yield return FileReference.Combine(GetGeneratedConfigDir(ProjectDir), PlatformName, BaseIniName + ".ini");
			}
		}
        /// <summary>
        /// Returns a list of INI filenames for the given project
        /// </summary>
        public static IEnumerable <FileReference> EnumerateConfigFileLocations(ConfigHierarchyType Type, DirectoryReference ProjectDir, UnrealTargetPlatform Platform)
        {
            string BaseIniName  = Enum.GetName(typeof(ConfigHierarchyType), Type);
            string PlatformName = GetIniPlatformName(Platform);

            foreach (string Layer in ConfigLayers)
            {
                bool bHasPlatformTag = Layer.Contains("{PLATFORM}");
                bool bHasProjectTag  = Layer.Contains("{PROJECT}");
                bool bHasUserTag     = Layer.Contains("{USER}");

                // skip certain layers if we are platform-less, project-less, or userdir-less
                if ((bHasPlatformTag && PlatformName == "None") ||
                    (bHasProjectTag && ProjectDir == null) ||
                    (bHasUserTag && GetUserDir() == null))
                {
                    continue;
                }

                string LayerPath = PerformBasicReplacements(Layer, BaseIniName);

                // we only expand engine/project inis
                if (Layer.Contains("{ENGINE}") || Layer.Contains("{PROJECT}"))
                {
                    foreach (ConfigLayerExpansion Expansion in ConfigLayerExpansions)
                    {
                        // expansion replacements
                        string ExpandedPath = PerformExpansionReplacements(Expansion, LayerPath);

                        // if nothing was replaced, then skip it, as it won't change anything
                        if (ExpandedPath == null)
                        {
                            continue;
                        }

                        // now go up the ini parent chain
                        if (bHasPlatformTag)
                        {
                            DataDrivenPlatformInfo.ConfigDataDrivenPlatformInfo Info = DataDrivenPlatformInfo.GetDataDrivenInfoForPlatform(PlatformName);
                            if (Info != null && Info.IniParentChain != null)
                            {
                                // the IniParentChain
                                foreach (string ParentPlatform in Info.IniParentChain)
                                {
                                    // @note: We are using the ParentPlatform as both PlatformExtensionName _and_ IniPlatformName. This is because the parent
                                    // may not even exist as a UnrealTargetPlatform, and all we have is a string to look up, and it would just get the same
                                    // string back, if we did look it up. This could become an issue if Win64 becomes a PlatformExtension, and wants to have
                                    // a parent Platform, of ... something. This is likely to never be an issue, but leaving this note here just in case.
                                    yield return(new FileReference(PerformFinalExpansions(ExpandedPath, ParentPlatform, ProjectDir)));
                                }
                            }
                            // always yield the active platform last
                            yield return(new FileReference(PerformFinalExpansions(ExpandedPath, PlatformName, ProjectDir)));
                        }
                        else
                        {
                            yield return(new FileReference(PerformFinalExpansions(ExpandedPath, "", ProjectDir)));
                        }
                    }
                }
                else
                {
                    yield return(new FileReference(LayerPath));
                }
            }

            // Find all the generated config files
            foreach (FileReference GeneratedConfigFile in EnumerateGeneratedConfigFileLocations(Type, ProjectDir, Platform))
            {
                yield return(GeneratedConfigFile);
            }
        }