|
|
|
|
| using UnrealBuildTool;
|
| using System;
|
| using System.IO;
|
| using EpicGames.Core;
|
| using System.Collections.Generic;
|
| using UnrealBuildBase;
|
| using Microsoft.Extensions.Logging;
|
|
|
| public class LyraGameTarget : TargetRules
|
| {
|
| public LyraGameTarget(TargetInfo Target) : base(Target)
|
| {
|
| Type = TargetType.Game;
|
|
|
| ExtraModuleNames.AddRange(new string[] { "LyraGame" });
|
|
|
| LyraGameTarget.ApplySharedLyraTargetSettings(this);
|
| }
|
|
|
| private static bool bHasWarnedAboutShared = false;
|
|
|
| internal static void ApplySharedLyraTargetSettings(TargetRules Target)
|
| {
|
| ILogger Logger = Target.Logger;
|
|
|
| Target.DefaultBuildSettings = BuildSettingsVersion.V5;
|
| Target.IncludeOrderVersion = EngineIncludeOrderVersion.Latest;
|
|
|
| bool bIsTest = Target.Configuration == UnrealTargetConfiguration.Test;
|
| bool bIsShipping = Target.Configuration == UnrealTargetConfiguration.Shipping;
|
| bool bIsDedicatedServer = Target.Type == TargetType.Server;
|
| if (Target.BuildEnvironment == TargetBuildEnvironment.Unique)
|
| {
|
| Target.CppCompileWarningSettings.ShadowVariableWarningLevel = WarningLevel.Error;
|
|
|
| Target.bUseLoggingInShipping = true;
|
| Target.bTrackRHIResourceInfoForTest = true;
|
|
|
| if (bIsShipping && !bIsDedicatedServer)
|
| {
|
|
|
| Target.bDisableUnverifiedCertificates = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| }
|
|
|
| if (bIsShipping || bIsTest)
|
| {
|
|
|
| Target.bAllowGeneratedIniWhenCooked = false;
|
| Target.bAllowNonUFSIniWhenCooked = false;
|
| }
|
|
|
| if (Target.Type != TargetType.Editor)
|
| {
|
|
|
| Target.DisablePlugins.Add("OpenImageDenoise");
|
|
|
|
|
| Target.GlobalDefinitions.Add("UE_ASSETREGISTRY_INDIRECT_ASSETDATA_POINTERS=1");
|
| }
|
|
|
| LyraGameTarget.ConfigureGameFeaturePlugins(Target);
|
| }
|
| else
|
| {
|
|
|
|
|
|
|
|
|
|
|
| if (Target.Type == TargetType.Editor)
|
| {
|
| LyraGameTarget.ConfigureGameFeaturePlugins(Target);
|
| }
|
| else
|
| {
|
|
|
| if (!bHasWarnedAboutShared)
|
| {
|
| bHasWarnedAboutShared = true;
|
| Logger.LogWarning("LyraGameEOS and dynamic target options are disabled when packaging from an installed version of the engine");
|
| }
|
| }
|
| }
|
| }
|
|
|
| static public bool ShouldEnableAllGameFeaturePlugins(TargetRules Target)
|
| {
|
| if (Target.Type == TargetType.Editor)
|
| {
|
|
|
|
|
|
|
| }
|
|
|
| bool bIsBuildMachine = (Environment.GetEnvironmentVariable("IsBuildMachine") == "1");
|
| if (bIsBuildMachine)
|
| {
|
|
|
|
|
| }
|
|
|
|
|
|
|
| return false;
|
| }
|
|
|
| private static Dictionary<string, JsonObject> AllPluginRootJsonObjectsByName = new Dictionary<string, JsonObject>();
|
|
|
|
|
|
|
|
|
|
|
| static public void ConfigureGameFeaturePlugins(TargetRules Target)
|
| {
|
| ILogger Logger = Target.Logger;
|
| Log.TraceInformationOnce("Compiling GameFeaturePlugins in branch {0}", Target.Version.BranchName);
|
|
|
| bool bBuildAllGameFeaturePlugins = ShouldEnableAllGameFeaturePlugins(Target);
|
|
|
|
|
| List<FileReference> CombinedPluginList = new List<FileReference>();
|
|
|
| List<DirectoryReference> GameFeaturePluginRoots = Unreal.GetExtensionDirs(Target.ProjectFile.Directory, Path.Combine("Plugins", "GameFeatures"));
|
| foreach (DirectoryReference SearchDir in GameFeaturePluginRoots)
|
| {
|
| CombinedPluginList.AddRange(PluginsBase.EnumeratePlugins(SearchDir));
|
| }
|
|
|
| if (CombinedPluginList.Count > 0)
|
| {
|
| Dictionary<string, List<string>> AllPluginReferencesByName = new Dictionary<string, List<string>>();
|
|
|
| foreach (FileReference PluginFile in CombinedPluginList)
|
| {
|
| if (PluginFile != null && FileReference.Exists(PluginFile))
|
| {
|
| bool bEnabled = false;
|
| bool bForceDisabled = false;
|
| try
|
| {
|
| JsonObject RawObject;
|
| if (!AllPluginRootJsonObjectsByName.TryGetValue(PluginFile.GetFileNameWithoutExtension(), out RawObject))
|
| {
|
| RawObject = JsonObject.Read(PluginFile);
|
| AllPluginRootJsonObjectsByName.Add(PluginFile.GetFileNameWithoutExtension(), RawObject);
|
| }
|
|
|
|
|
|
|
|
|
| bool bEnabledByDefault = false;
|
| if (!RawObject.TryGetBoolField("EnabledByDefault", out bEnabledByDefault) || bEnabledByDefault == true)
|
| {
|
|
|
| }
|
|
|
|
|
|
|
| bool bExplicitlyLoaded = false;
|
| if (!RawObject.TryGetBoolField("ExplicitlyLoaded", out bExplicitlyLoaded) || bExplicitlyLoaded == false)
|
| {
|
| Logger.LogWarning("GameFeaturePlugin {0}, does not set ExplicitlyLoaded to true. This is required for GameFeaturePlugins.", PluginFile.GetFileNameWithoutExtension());
|
| }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| if (bBuildAllGameFeaturePlugins)
|
| {
|
|
|
| bEnabled = true;
|
| }
|
|
|
|
|
| bool bEditorOnly = false;
|
| if (RawObject.TryGetBoolField("EditorOnly", out bEditorOnly))
|
| {
|
| if (bEditorOnly && (Target.Type != TargetType.Editor) && !bBuildAllGameFeaturePlugins)
|
| {
|
|
|
| bForceDisabled = true;
|
| }
|
| }
|
| else
|
| {
|
|
|
| }
|
|
|
|
|
| string RestrictToBranch;
|
| if (RawObject.TryGetStringField("RestrictToBranch", out RestrictToBranch))
|
| {
|
| if (!Target.Version.BranchName.Equals(RestrictToBranch, StringComparison.OrdinalIgnoreCase))
|
| {
|
|
|
| bForceDisabled = true;
|
| Logger.LogDebug("GameFeaturePlugin {Name} was marked as restricted to other branches. Disabling.", PluginFile.GetFileNameWithoutExtension());
|
| }
|
| else
|
| {
|
| Logger.LogDebug("GameFeaturePlugin {Name} was marked as restricted to this branch. Leaving enabled.", PluginFile.GetFileNameWithoutExtension());
|
| }
|
| }
|
|
|
|
|
| bool bNeverBuild = false;
|
| if (RawObject.TryGetBoolField("NeverBuild", out bNeverBuild) && bNeverBuild)
|
| {
|
|
|
| bForceDisabled = true;
|
| Logger.LogDebug("GameFeaturePlugin {Name} was marked as NeverBuild, disabling.", PluginFile.GetFileNameWithoutExtension());
|
| }
|
|
|
|
|
| JsonObject[] PluginReferencesArray;
|
| if (RawObject.TryGetObjectArrayField("Plugins", out PluginReferencesArray))
|
| {
|
| foreach (JsonObject ReferenceObject in PluginReferencesArray)
|
| {
|
| bool bRefEnabled = false;
|
| if (ReferenceObject.TryGetBoolField("Enabled", out bRefEnabled) && bRefEnabled == true)
|
| {
|
| string PluginReferenceName;
|
| if (ReferenceObject.TryGetStringField("Name", out PluginReferenceName))
|
| {
|
| string ReferencerName = PluginFile.GetFileNameWithoutExtension();
|
| if (!AllPluginReferencesByName.ContainsKey(ReferencerName))
|
| {
|
| AllPluginReferencesByName[ReferencerName] = new List<string>();
|
| }
|
| AllPluginReferencesByName[ReferencerName].Add(PluginReferenceName);
|
| }
|
| }
|
| }
|
| }
|
| }
|
| catch (Exception ParseException)
|
| {
|
| Logger.LogWarning("Failed to parse GameFeaturePlugin file {Name}, disabling. Exception: {1}", PluginFile.GetFileNameWithoutExtension(), ParseException.Message);
|
| bForceDisabled = true;
|
| }
|
|
|
|
|
| if (bForceDisabled)
|
| {
|
| bEnabled = false;
|
| }
|
|
|
|
|
| Logger.LogDebug("ConfigureGameFeaturePlugins() has decided to {Action} feature {Name}", bEnabled ? "enable" : (bForceDisabled ? "disable" : "ignore"), PluginFile.GetFileNameWithoutExtension());
|
|
|
|
|
| if (bEnabled)
|
| {
|
| Target.EnablePlugins.Add(PluginFile.GetFileNameWithoutExtension());
|
| }
|
| else if (bForceDisabled)
|
| {
|
| Target.DisablePlugins.Add(PluginFile.GetFileNameWithoutExtension());
|
| }
|
| }
|
| }
|
|
|
|
|
|
|
| }
|
| }
|
| }
|
|
|