Exemple #1
0
        /// <summary>
        /// NOTE: This function should mirror FPluginManager::ConfigureEnabledPluginForTarget
        /// </summary>
        static bool ConfigureEnabledPluginForTarget(PluginReferenceDescriptor FirstReference, ProjectDescriptor ProjectDescriptor, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, TargetType TargetType, bool bLoadPluginsForTargetPlatforms, Dictionary <string, PluginInfo> AllPlugins, Dictionary <string, PluginInfo> EnabledPlugins, out PluginReferenceDescriptor OutMissingPlugin)
        {
            if (!EnabledPlugins.ContainsKey(FirstReference.Name))
            {
                // Set of plugin names we've added to the queue for processing
                HashSet <string> NewPluginNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                NewPluginNames.Add(FirstReference.Name);

                // Queue of plugin references to consider
                List <PluginReferenceDescriptor> NewPluginReferences = new List <PluginReferenceDescriptor>();
                NewPluginReferences.Add(FirstReference);

                // Loop through the queue of plugin references that need to be enabled, queuing more items as we go
                for (int Idx = 0; Idx < NewPluginReferences.Count; Idx++)
                {
                    PluginReferenceDescriptor Reference = NewPluginReferences[Idx];

                    // Check if the plugin is required for this platform
                    if (!Reference.IsEnabledForPlatform(Platform) || !Reference.IsEnabledForTargetConfiguration(Configuration) || !Reference.IsEnabledForTarget(TargetType))
                    {
                        Log.TraceLog("Ignoring plugin '{0}' for platform/configuration", Reference.Name);
                        continue;
                    }

                    // Check if the plugin is required for this platform
                    if (!bLoadPluginsForTargetPlatforms && !Reference.IsSupportedTargetPlatform(Platform))
                    {
                        Log.TraceLog("Ignoring plugin '{0}' due to unsupported platform", Reference.Name);
                        continue;
                    }

                    // Find the plugin being enabled
                    PluginInfo Plugin;
                    if (!AllPlugins.TryGetValue(Reference.Name, out Plugin))
                    {
                        // Ignore any optional plugins
                        if (Reference.bOptional)
                        {
                            Log.TraceLog("Ignored optional reference to '%s' plugin; plugin was not found.", Reference.Name);
                            continue;
                        }

                        // Add it to the missing list
                        OutMissingPlugin = Reference;
                        return(false);
                    }

                    // Check the plugin supports this platform
                    if (!bLoadPluginsForTargetPlatforms && !Plugin.Descriptor.SupportsTargetPlatform(Platform))
                    {
                        Log.TraceLog("Ignoring plugin '{0}' due to unsupported platform in plugin descriptor", Reference.Name);
                        continue;
                    }

                    // Check that this plugin supports the current program
                    if (TargetType == TargetType.Program && !Plugin.Descriptor.SupportedPrograms.Contains(TargetName))
                    {
                        Log.TraceLog("Ignoring plugin '{0}' due to absence from the supported programs list", Reference.Name);
                        continue;
                    }

                    // Skip loading Enterprise plugins when project is not an Enterprise project
                    if (Plugin.Type == PluginType.Enterprise && ProjectDescriptor != null && !ProjectDescriptor.IsEnterpriseProject)
                    {
                        Log.TraceLog("Ignoring plugin '{0}' due to not being an enterprise project", Reference.Name);
                        continue;
                    }

                    // Add references to all its dependencies
                    if (Plugin.Descriptor.Plugins != null)
                    {
                        foreach (PluginReferenceDescriptor NextReference in Plugin.Descriptor.Plugins)
                        {
                            if (!EnabledPlugins.ContainsKey(NextReference.Name) && !NewPluginNames.Contains(NextReference.Name))
                            {
                                NewPluginNames.Add(NextReference.Name);
                                NewPluginReferences.Add(NextReference);
                            }
                        }
                    }

                    // Add the plugin
                    EnabledPlugins.Add(Plugin.Name, Plugin);
                }
            }

            OutMissingPlugin = null;
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// NOTE: This function must mirror FPluginManager::GetCodePluginsForTarget
        /// </summary>
        static bool GetCodePluginsForTarget(ProjectDescriptor ProjectDescriptor, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, TargetType TargetType, HashSet <string> CodePluginNames, Dictionary <string, PluginInfo> AllPlugins, out PluginReferenceDescriptor OutMissingPlugin)
        {
            bool bLoadPluginsForTargetPlatforms = (TargetType == TargetType.Editor);

            // Map of all enabled plugins
            Dictionary <string, PluginInfo> EnabledPlugins = new Dictionary <string, PluginInfo>(StringComparer.OrdinalIgnoreCase);

            // Keep a set of all the plugin names that have been configured. We read configuration data from different places, but only configure a plugin from the first place that it's referenced.
            HashSet <string> ConfiguredPluginNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            bool bAllowEnginePluginsEnabledByDefault = true;

            // Find all the plugin references in the project file
            if (ProjectDescriptor != null)
            {
                bAllowEnginePluginsEnabledByDefault = !ProjectDescriptor.DisableEnginePluginsByDefault;
                if (ProjectDescriptor.Plugins != null)
                {
                    // Copy the plugin references, since we may modify the project if any plugins are missing
                    foreach (PluginReferenceDescriptor PluginReference in ProjectDescriptor.Plugins)
                    {
                        if (!ConfiguredPluginNames.Contains(PluginReference.Name))
                        {
                            PluginReferenceDescriptor MissingPlugin;
                            if (!ConfigureEnabledPluginForTarget(PluginReference, ProjectDescriptor, null, Platform, Configuration, TargetType, bLoadPluginsForTargetPlatforms, AllPlugins, EnabledPlugins, out MissingPlugin))
                            {
                                OutMissingPlugin = MissingPlugin;
                                return(false);
                            }
                            ConfiguredPluginNames.Add(PluginReference.Name);
                        }
                    }
                }
            }

            // Add the plugins which are enabled by default
            foreach (KeyValuePair <string, PluginInfo> PluginPair in AllPlugins)
            {
                if (PluginPair.Value.IsEnabledByDefault(bAllowEnginePluginsEnabledByDefault) && !ConfiguredPluginNames.Contains(PluginPair.Key))
                {
                    PluginReferenceDescriptor MissingPlugin;
                    if (!ConfigureEnabledPluginForTarget(new PluginReferenceDescriptor(PluginPair.Key, null, true), ProjectDescriptor, null, Platform, Configuration, TargetType, bLoadPluginsForTargetPlatforms, AllPlugins, EnabledPlugins, out MissingPlugin))
                    {
                        OutMissingPlugin = MissingPlugin;
                        return(false);
                    }
                    ConfiguredPluginNames.Add(PluginPair.Key);
                }
            }

            // Figure out which plugins have code
            bool bBuildDeveloperTools = (TargetType == TargetType.Editor || TargetType == TargetType.Program || (Configuration != UnrealTargetConfiguration.Test && Configuration != UnrealTargetConfiguration.Shipping));
            bool bRequiresCookedData  = (TargetType != TargetType.Editor);

            foreach (KeyValuePair <string, PluginInfo> Pair in EnabledPlugins)
            {
                if (Pair.Value.Descriptor.Modules != null)
                {
                    foreach (ModuleDescriptor Module in Pair.Value.Descriptor.Modules)
                    {
                        if (Module.IsCompiledInConfiguration(Platform, Configuration, null, TargetType, bBuildDeveloperTools, bRequiresCookedData))
                        {
                            CodePluginNames.Add(Pair.Key);
                            break;
                        }
                    }
                }
            }

            OutMissingPlugin = null;
            return(true);
        }