/// <summary> /// Writes information about the targets in an assembly to a file /// </summary> /// <param name="ProjectFile">The project file for the targets being built</param> /// <param name="Assembly">The rules assembly for this target</param> /// <param name="OutputFile">Output file to write to</param> /// <param name="Arguments"></param> public static void WriteTargetInfo(FileReference ProjectFile, RulesAssembly Assembly, FileReference OutputFile, CommandLineArguments Arguments) { // Construct all the targets in this assembly List <string> TargetNames = new List <string>(); Assembly.GetAllTargetNames(TargetNames, false); // Write the output file DirectoryReference.CreateDirectory(OutputFile.Directory); using (JsonWriter Writer = new JsonWriter(OutputFile)) { Writer.WriteObjectStart(); Writer.WriteArrayStart("Targets"); foreach (string TargetName in TargetNames) { // skip target rules that are platform extension or platform group specializations string[] TargetPathSplit = TargetName.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); if (TargetPathSplit.Length > 1 && (UnrealTargetPlatform.IsValidName(TargetPathSplit.Last()) || UnrealPlatformGroup.IsValidName(TargetPathSplit.Last()))) { continue; } // Construct the rules object TargetRules TargetRules; try { string Architecture = UEBuildPlatform.GetBuildPlatform(BuildHostPlatform.Current.Platform).GetDefaultArchitecture(ProjectFile); TargetRules = Assembly.CreateTargetRules(TargetName, BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development, Architecture, ProjectFile, Arguments); } catch (Exception Ex) { Log.TraceWarning("Unable to construct target rules for {0}", TargetName); Log.TraceVerbose(ExceptionUtils.FormatException(Ex)); continue; } // Write the target info Writer.WriteObjectStart(); Writer.WriteValue("Name", TargetName); Writer.WriteValue("Path", Assembly.GetTargetFileName(TargetName).ToString()); Writer.WriteValue("Type", TargetRules.Type.ToString()); Writer.WriteObjectEnd(); } Writer.WriteArrayEnd(); Writer.WriteObjectEnd(); } }
private static void ParsePlatformConfiguration(string PlatformConfiguration) { // Trim whitespace at the beginning. PlatformConfiguration = PlatformConfiguration.Trim(); // Remove brackets. PlatformConfiguration = PlatformConfiguration.TrimStart('('); PlatformConfiguration = PlatformConfiguration.TrimEnd(')'); bool bCanCreateEntry = true; string ConfigurationName; UnrealTargetConfiguration Configuration = UnrealTargetConfiguration.Unknown; if (ParseSubValue(PlatformConfiguration, "Configuration=", out ConfigurationName)) { Enum.TryParse(ConfigurationName, out Configuration); } if (Configuration == UnrealTargetConfiguration.Unknown) { Log.TraceWarning("Unable to read configuration from {0}", PlatformConfiguration); bCanCreateEntry = false; } string PlatformName; if (ParseSubValue(PlatformConfiguration, "PlatformName=", out PlatformName)) { if (!UnrealTargetPlatform.IsValidName(PlatformName)) { Log.TraceWarning("Unable to read platform from {0}", PlatformConfiguration); bCanCreateEntry = false; } } string PlatformTypeName; TargetType PlatformType = TargetType.Game; if (ParseSubValue(PlatformConfiguration, "PlatformType=", out PlatformTypeName)) { if (!Enum.TryParse(PlatformTypeName, out PlatformType)) { Log.TraceWarning("Unable to read Platform Type from {0}, defaulting to Game", PlatformConfiguration); PlatformType = TargetType.Game; } } if (PlatformType == TargetType.Program) { Log.TraceWarning("Program is not a valid PlatformType for an Installed Platform, defaulting to Game"); PlatformType = TargetType.Game; } string Architecture; ParseSubValue(PlatformConfiguration, "Architecture=", out Architecture); string RequiredFile; if (ParseSubValue(PlatformConfiguration, "RequiredFile=", out RequiredFile)) { RequiredFile = FileReference.Combine(UnrealBuildTool.RootDirectory, RequiredFile).ToString(); } string ProjectTypeName; EProjectType ProjectType = EProjectType.Any; if (ParseSubValue(PlatformConfiguration, "ProjectType=", out ProjectTypeName)) { Enum.TryParse(ProjectTypeName, out ProjectType); } if (ProjectType == EProjectType.Unknown) { Log.TraceWarning("Unable to read project type from {0}", PlatformConfiguration); bCanCreateEntry = false; } string CanBeDisplayedString; bool bCanBeDisplayed = false; if (ParseSubValue(PlatformConfiguration, "bCanBeDisplayed=", out CanBeDisplayedString)) { bCanBeDisplayed = Convert.ToBoolean(CanBeDisplayedString); } if (bCanCreateEntry) { InstalledPlatformConfigurations.Add(new InstalledPlatformConfiguration(Configuration, UnrealTargetPlatform.Parse(PlatformName), PlatformType, Architecture, RequiredFile, ProjectType, bCanBeDisplayed)); } }