Ejemplo n.º 1
0
        private static string GetLayerPath(ConfigLayer Layer, string PlatformExtensionName, string IniPlatformName, DirectoryReference ProjectDir, string BaseIniName,
                                           out bool bHasPlatformTag, out bool bHasProjectTag, out bool bHasExpansionTag)
        {
            // cache some platform extension information that can be used inside the loops
            string PlatformExtensionEngineConfigDir  = DirectoryReference.Combine(UnrealBuildTool.EnginePlatformExtensionsDirectory, PlatformExtensionName).FullName;
            string PlatformExtensionProjectConfigDir = ProjectDir != null?DirectoryReference.Combine(UnrealBuildTool.ProjectPlatformExtensionsDirectory(ProjectDir), PlatformExtensionName).FullName : null;

            bool bHasPlatformExtensionEngineConfigDir  = Directory.Exists(PlatformExtensionEngineConfigDir);
            bool bHasPlatformExtensionProjectConfigDir = PlatformExtensionProjectConfigDir != null && Directory.Exists(PlatformExtensionProjectConfigDir);

            bHasPlatformTag  = Layer.Path.Contains("{PLATFORM}");
            bHasProjectTag   = Layer.Path.Contains("{PROJECT}");
            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 && IniPlatformName == "None") ||
                (bHasProjectTag && ProjectDir == null) ||
                (bHasUserTag && GetUserDir() == null))
            {
                return(null);
            }

            // 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);
            LayerPath = LayerPath.Replace("{USER}", GetUserDir());

            return(LayerPath);
        }
Ejemplo n.º 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);

			// 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");
			}
		}