Пример #1
0
        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"));
        }
Пример #2
0
        private void WriteLaunchFile()
        {
            JsonFile   OutFile   = new JsonFile();
            EDebugMode DebugMode = (HostPlatform == UnrealTargetPlatform.Win64) ? EDebugMode.VS : EDebugMode.GDB;

            OutFile.BeginRootObject();
            {
                OutFile.AddField("version", "0.2.0");
                OutFile.BeginArray("configurations");
                {
                    List <ProjectFile> Projects = new List <ProjectFile>(GeneratedProjectFiles);
                    Projects.Sort((A, B) => { return(A.ProjectFilePath.GetFileNameWithoutExtension().CompareTo(B.ProjectFilePath.GetFileNameWithoutExtension())); });

                    foreach (ProjectFile Project in AllProjectFiles)
                    {
                        if (Project.ProjectFilePath.GetExtension() == ProjectFileExtension)
                        {
                            foreach (ProjectTarget Target in Project.ProjectTargets)
                            {
                                List <UnrealTargetConfiguration> Configs = new List <UnrealTargetConfiguration>();
                                Target.TargetRules.GetSupportedConfigurations(ref Configs, true);

                                foreach (UnrealTargetConfiguration Config in Configs)
                                {
                                    if (SupportedConfigurations.Contains(Config))
                                    {
                                        FileReference Executable = GetExecutableFilename(Project, Target, HostPlatform, Config);
                                        string        Name       = Target.TargetRules == null?Project.ProjectFilePath.GetFileNameWithoutExtension() : Target.TargetRules.Name;

                                        string LaunchTaskName      = $"{Name} {HostPlatform} {Config} Build";
                                        string ExecutableDirectory = "${workspaceRoot}/" + Executable.Directory.MakeRelativeTo(UnrealBuildTool.RootDirectory).ToString().Replace("\\", "/");

                                        OutFile.BeginObject();
                                        {
                                            OutFile.AddField("name", Target.TargetRules.Name + " (" + Config.ToString() + ")");
                                            OutFile.AddField("request", "launch");
                                            OutFile.AddField("preLaunchTask", LaunchTaskName);
                                            OutFile.AddField("program", ExecutableDirectory + "/" + Executable.GetFileName());

                                            OutFile.BeginArray("args");
                                            {
                                            }
                                            OutFile.EndArray();
                                            OutFile.AddField("stopAtEntry", true);
                                            OutFile.AddField("cwd", ExecutableDirectory);
                                            OutFile.BeginArray("environment");
                                            {
                                            }
                                            OutFile.EndArray();
                                            OutFile.AddField("externalConsole", true);

                                            switch (DebugMode)
                                            {
                                            case EDebugMode.VS:
                                            {
                                                OutFile.AddField("type", "cppvsdbg");
                                                break;
                                            }

                                            case EDebugMode.GDB:
                                            {
                                                OutFile.AddField("type", "cppdbg");
                                                OutFile.AddField("MIMode", "lldb");
                                                break;
                                            }
                                            }
                                        }
                                        OutFile.EndObject();
                                    }
                                }
                            }
                        }
                        else if (Project.ProjectFilePath.GetExtension() == ".csproj")
                        {
                            /*
                             * foreach (ProjectTarget Target in Project.ProjectTargets)
                             * {
                             *      foreach (UnrealTargetConfiguration Config in Target.ExtraSupportedConfigurations)
                             *      {
                             *              string TaskName = $"{Project.ProjectFilePath.GetFileNameWithoutExtension()} ({Config})";
                             *              string BuildTaskName = $"{Project.ProjectFilePath.GetFileNameWithoutExtension()} {HostPlatform} {Config} Build";
                             *              FileReference Executable = GetExecutableFilename(Project, Target, HostPlatform, Config);
                             *
                             *              OutFile.BeginObject();
                             *              {
                             *                      OutFile.AddField("name", TaskName);
                             *                      OutFile.AddField("type", "coreclr");
                             *                      OutFile.AddField("request", "launch");
                             *                      OutFile.AddField("preLaunchTask", BuildTaskName);
                             *                      OutFile.AddField("program", Executable.ToString());
                             *                      OutFile.BeginArray("args");
                             *                      {
                             *
                             *                      }
                             *                      OutFile.EndArray();
                             *              }
                             *              OutFile.EndObject();
                             *      }
                             * }
                             */
                        }
                    }
                }
                OutFile.EndArray();
            }
            OutFile.EndRootObject();

            OutFile.Write(FileReference.Combine(VSCodeDir, "launch.json"));
        }
Пример #3
0
        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"));
        }