/// <summary> /// Constructor /// </summary> /// <param name="Writer">The text writer to output to</param> /// <param name="bLeaveOpen">Whether to leave the writer open when the object is disposed</param> /// <param name="Style">The output style</param> public JsonWriter(TextWriter Writer, bool bLeaveOpen = false, JsonWriterStyle Style = JsonWriterStyle.Readable) { this.Writer = Writer; this.bLeaveOpen = bLeaveOpen; this.Style = Style; Indent = ""; }
/// <summary> /// Constructor /// </summary> /// <param name="FileName">File to write to</param> /// <param name="Style">Should use packed JSON or not</param> public JsonWriter(FileReference FileName, JsonWriterStyle Style = JsonWriterStyle.Readable) : this(new StreamWriter(FileName.FullName)) { this.Style = Style; }
/// <summary> /// Write project file info in JSON file. /// For every combination of <c>UnrealTargetPlatform</c>, <c>UnrealTargetConfiguration</c> and <c>TargetType</c> /// will be generated separate JSON file. /// Project file will be stored: /// For UE4: {UE4Root}/Engine/Intermediate/ProjectFiles/.Rider/{Platform}/{Configuration}/{TargetType}/{ProjectName}.json /// For game: {GameRoot}/Intermediate/ProjectFiles/.Rider/{Platform}/{Configuration}/{TargetType}/{ProjectName}.json /// </summary> /// <remarks> /// * <c>UnrealTargetPlatform.Win32</c> will be always ignored. /// * <c>TargetType.Editor</c> will be generated for current platform only and will ignore <c>UnrealTargetConfiguration.Test</c> and <c>UnrealTargetConfiguration.Shipping</c> configurations /// * <c>TargetType.Program</c> will be generated for current platform only and <c>UnrealTargetConfiguration.Development</c> configuration only /// </remarks> /// <param name="InPlatforms"></param> /// <param name="InConfigurations"></param> /// <param name="PlatformProjectGenerators"></param> /// <param name="Minimize"></param> /// <returns></returns> public bool WriteProjectFile(List <UnrealTargetPlatform> InPlatforms, List <UnrealTargetConfiguration> InConfigurations, PlatformProjectGeneratorCollection PlatformProjectGenerators, JsonWriterStyle Minimize) { string ProjectName = ProjectFilePath.GetFileNameWithoutAnyExtensions(); DirectoryReference ProjectRootFolder = RootPath; List <Tuple <FileReference, UEBuildTarget> > FileToTarget = new List <Tuple <FileReference, UEBuildTarget> >(); foreach (UnrealTargetPlatform Platform in InPlatforms) { foreach (UnrealTargetConfiguration Configuration in InConfigurations) { foreach (ProjectTarget ProjectTarget in ProjectTargets) { if (TargetTypes.Any() && !TargetTypes.Contains(ProjectTarget.TargetRules.Type)) { continue; } // Skip Programs for all configs except for current platform + Development & Debug configurations if (ProjectTarget.TargetRules.Type == TargetType.Program && (BuildHostPlatform.Current.Platform != Platform || !(Configuration == UnrealTargetConfiguration.Development || Configuration == UnrealTargetConfiguration.Debug))) { continue; } // Skip Editor for all platforms except for current platform if (ProjectTarget.TargetRules.Type == TargetType.Editor && (BuildHostPlatform.Current.Platform != Platform || (Configuration == UnrealTargetConfiguration.Test || Configuration == UnrealTargetConfiguration.Shipping))) { continue; } DirectoryReference ConfigurationFolder = DirectoryReference.Combine(ProjectRootFolder, Platform.ToString(), Configuration.ToString()); DirectoryReference TargetFolder = DirectoryReference.Combine(ConfigurationFolder, ProjectTarget.TargetRules.Type.ToString()); string DefaultArchitecture = UEBuildPlatform .GetBuildPlatform(Platform) .GetDefaultArchitecture(ProjectTarget.UnrealProjectFilePath); TargetDescriptor TargetDesc = new TargetDescriptor(ProjectTarget.UnrealProjectFilePath, ProjectTarget.Name, Platform, Configuration, DefaultArchitecture, Arguments); try { UEBuildTarget BuildTarget = UEBuildTarget.Create(TargetDesc, false, false); FileReference OutputFile = FileReference.Combine(TargetFolder, $"{ProjectName}.json"); FileToTarget.Add(Tuple.Create(OutputFile, BuildTarget)); } catch (Exception Ex) { Log.TraceWarning("Exception while generating include data for Target:{0}, Platform: {1}, Configuration: {2}", TargetDesc.Name, Platform.ToString(), Configuration.ToString()); Log.TraceWarning(Ex.ToString()); } } } } foreach (Tuple <FileReference, UEBuildTarget> tuple in FileToTarget) { try { CurrentTarget = tuple.Item2; CurrentTarget.PreBuildSetup(); SerializeTarget(tuple.Item1, CurrentTarget, Minimize); } catch (Exception Ex) { Log.TraceWarning("Exception while generating include data for Target:{0}, Platform: {1}, Configuration: {2}", tuple.Item2.AppName, tuple.Item2.Platform.ToString(), tuple.Item2.Configuration.ToString()); Log.TraceWarning(Ex.ToString()); } } return(true); }
/// <summary> /// Constructor /// </summary> /// <param name="FileName">File to write to</param> /// <param name="Style">Should use packed JSON or not</param> public JsonWriter(string FileName, JsonWriterStyle Style = JsonWriterStyle.Readable) : this(new StreamWriter(FileName)) { this.Style = Style; }
private void SerializeTarget(FileReference OutputFile, UEBuildTarget BuildTarget, JsonWriterStyle Minimize) { DirectoryReference.CreateDirectory(OutputFile.Directory); using (JsonWriter Writer = new JsonWriter(OutputFile, Minimize)) { ExportTarget(BuildTarget, Writer); } }