static void AddPluginToAgenda(UE4Build.BuildAgenda Agenda, string PluginFileName, PluginDescriptor Plugin, string TargetName, TargetRules.TargetType TargetType, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, List<string> ReceiptFileNames, string InAdditionalArgs)
    {
        // Find a list of modules that need to be built for this plugin
        List<string> ModuleNames = new List<string>();
        foreach(ModuleDescriptor Module in Plugin.Modules)
        {
            bool bBuildDeveloperTools = (TargetType == TargetRules.TargetType.Editor || TargetType == TargetRules.TargetType.Program);
            bool bBuildEditor = (TargetType == TargetRules.TargetType.Editor);
            if(Module.IsCompiledInConfiguration(Platform, TargetType, bBuildDeveloperTools, bBuildEditor))
            {
                ModuleNames.Add(Module.Name);
            }
        }

        // Add these modules to the build agenda
        if(ModuleNames.Count > 0)
        {
            string Arguments = String.Format("-plugin {0}", CommandUtils.MakePathSafeToUseWithCommandLine(PluginFileName));
            foreach(string ModuleName in ModuleNames)
            {
                Arguments += String.Format(" -module {0}", ModuleName);
            }

            string ReceiptFileName = BuildReceipt.GetDefaultPath(Path.GetDirectoryName(PluginFileName), TargetName, Platform, Configuration, "");
            Arguments += String.Format(" -receipt {0}", CommandUtils.MakePathSafeToUseWithCommandLine(ReceiptFileName));
            ReceiptFileNames.Add(ReceiptFileName);

            if(!String.IsNullOrEmpty(InAdditionalArgs))
            {
                Arguments += InAdditionalArgs;
            }

            Agenda.AddTarget(TargetName, Platform, Configuration, InAddArgs: Arguments);
        }
    }