Beispiel #1
0
        /// <summary>
        /// Determines a target name based on the type of target we're trying to build
        /// </summary>
        /// <param name="Type">The type of target to look for</param>
        /// <param name="Platform">The platform being built</param>
        /// <param name="Configuration">The configuration being built</param>
        /// <param name="Architecture">The architecture being built</param>
        /// <param name="ProjectFile">Project file for the target being built</param>
        /// <param name="Version">The current engine version information</param>
        /// <returns>Name of the target for the given type</returns>
        public string GetTargetNameByType(TargetType Type, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string Architecture, FileReference ProjectFile, ReadOnlyBuildVersion Version)
        {
            // Create all the targets in this assembly
            List <string> Matches = new List <string>();

            foreach (KeyValuePair <string, FileReference> TargetPair in TargetNameToTargetFile)
            {
                TargetRules Rules = CreateTargetRulesInstance(TargetPair.Key + "Target", new TargetInfo(TargetPair.Key, Platform, Configuration, Architecture, ProjectFile, Version));
                if (Rules.Type == Type)
                {
                    Matches.Add(TargetPair.Key);
                }
            }

            // If we got a result, return it. If there were multiple results, fail.
            if (Matches.Count == 0)
            {
                if (Parent == null)
                {
                    throw new BuildException("Unable to find target of type '{0}' for project '{1}'", Type, ProjectFile);
                }
                else
                {
                    return(Parent.GetTargetNameByType(Type, Platform, Configuration, Architecture, ProjectFile, Version));
                }
            }
            else
            {
                if (Matches.Count == 1)
                {
                    return(Matches[0]);
                }
                else
                {
                    throw new BuildException("Found multiple targets with TargetType={0}: {1}", Type, String.Join(", ", Matches));
                }
            }
        }