private void WriteCppPropertiesFile() { JsonFile OutFile = new JsonFile(); List <string> PathList = new List <string>(); foreach (ProjectFile Project in GeneratedProjectFiles) { foreach (ProjectFile.SourceFile SourceFile in Project.SourceFiles) { if (SourceFile.Reference.GetExtension() == ".h") { string Path = "${workspaceRoot}/" + SourceFile.Reference.Directory.MakeRelativeTo(UnrealBuildTool.RootDirectory).Replace('\\', '/'); if (!PathList.Contains(Path)) { PathList.Add(Path); } } } } PathList.Sort(); string[] Paths = PathList.ToArray(); OutFile.BeginRootObject(); { OutFile.BeginArray("configurations"); { OutFile.BeginObject(); { OutFile.AddField("name", "Win32"); OutFile.BeginArray("includePath"); { foreach (var Path in Paths) { OutFile.AddUnnamedField(Path); } } OutFile.EndArray(); OutFile.BeginArray("defines"); { OutFile.AddUnnamedField("_DEBUG"); OutFile.AddUnnamedField("UNICODE"); } OutFile.EndArray(); } OutFile.EndObject(); } OutFile.EndArray(); } OutFile.EndRootObject(); OutFile.Write(FileReference.Combine(VSCodeDir, "c_cpp_properties.json")); }
private void WriteTasksFile() { JsonFile OutFile = new JsonFile(); OutFile.BeginRootObject(); { OutFile.AddField("version", "2.0.0"); OutFile.BeginArray("tasks"); { string[] Commands = { "Build", "Clean" }; foreach (ProjectFile Project in AllProjectFiles) { if (Project.ProjectFilePath.GetExtension().Contains(ProjectFileExtension)) { List <PlatformAndConfigToBuild> ToBuildList = new List <PlatformAndConfigToBuild>(); GatherBuildTargets(Project, ToBuildList); foreach (PlatformAndConfigToBuild ToBuild in ToBuildList) { foreach (string Command in Commands) { string TaskName = $"{ToBuild.ProjectName} {ToBuild.Platform.ToString()} {ToBuild.Config} {Command}"; List <string> ExtraParams = new List <string>(); string BatchFilename = null; switch (HostPlatform) { case UnrealTargetPlatform.Win64: { BatchFilename = "${workspaceRoot}/Engine/Build/BatchFiles/" + Command + ".bat"; break; } case UnrealTargetPlatform.Mac: { BatchFilename = "${workspaceRoot}/Engine/Build/BatchFiles/Mac/Buiild.sh"; break; } case UnrealTargetPlatform.Linux: { BatchFilename = "${workspaceRoot}/Engine/Build/BatchFiles/Linux/Build.sh"; break; } } OutFile.BeginObject(); { OutFile.AddField("taskName", TaskName); OutFile.AddField("command", BatchFilename); OutFile.BeginArray("args"); { OutFile.AddUnnamedField(ToBuild.ProjectName); OutFile.AddUnnamedField(ToBuild.Platform.ToString()); OutFile.AddUnnamedField(ToBuild.Config.ToString()); OutFile.AddUnnamedField("-waitmutex"); foreach (string ExtraParam in ExtraParams) { OutFile.AddUnnamedField(ExtraParam); } } OutFile.EndArray(); OutFile.AddField("problemMatcher", "$msCompile"); } OutFile.EndObject(); } } } else if (Project.ProjectFilePath.GetExtension() == ".csproj") { string CSProjectPath = Project.ProjectFilePath.MakeRelativeTo(UnrealBuildTool.RootDirectory).ToString().Replace('\\', '/'); foreach (ProjectTarget Target in Project.ProjectTargets) { UnrealTargetConfiguration[] CSharpConfigs = { UnrealTargetConfiguration.Debug, UnrealTargetConfiguration.Development }; foreach (UnrealTargetConfiguration Config in CSharpConfigs) { foreach (string Command in Commands) { string TaskName = $"{Project.ProjectFilePath.GetFileNameWithoutExtension()} {HostPlatform} {Config} {Command}"; OutFile.BeginObject(); { OutFile.AddField("taskName", TaskName); if (HostPlatform == UnrealTargetPlatform.Win64) { OutFile.AddField("command", "dotnet"); } else { OutFile.AddField("command", "xbuild"); } OutFile.BeginArray("args"); { if (HostPlatform == UnrealTargetPlatform.Win64) { OutFile.AddUnnamedField(Command.ToLower()); } else { OutFile.AddUnnamedField("/t:" + Command.ToLower()); } OutFile.AddUnnamedField(CSProjectPath); } OutFile.EndArray(); } OutFile.AddField("problemMatcher", "$msCompile"); OutFile.EndObject(); } } } } } OutFile.EndArray(); } } OutFile.EndRootObject(); OutFile.Write(FileReference.Combine(VSCodeDir, "tasks.json")); }