Ejemplo n.º 1
0
        protected override bool WriteMasterProjectFile(ProjectFile UBTProject)
        {
            string SolutionFileName               = MasterProjectName + SolutionExtension;
            string CodeCompletionFile             = MasterProjectName + CodeCompletionFileName;
            string CodeCompletionPreProcessorFile = MasterProjectName + CodeCompletionPreProcessorFileName;

            string FullCodeLiteMasterFile                     = Path.Combine(MasterProjectPath.FullName, SolutionFileName);
            string FullCodeLiteCodeCompletionFile             = Path.Combine(MasterProjectPath.FullName, CodeCompletionFile);
            string FullCodeLiteCodeCompletionPreProcessorFile = Path.Combine(MasterProjectPath.FullName, CodeCompletionPreProcessorFile);

            //
            // HACK
            // TODO This is for now a hack. According to the original submitter, Eranif (a CodeLite developer) will support code completion folders in *.workspace files.
            // We create a separate file with all the folder name in it to copy manually into the code completion
            // filed of CodeLite workspace. (Workspace Settings/Code Completion -> copy the content of the file threre.)
            List <string> IncludeDirectories = new List <string>();
            List <string> PreProcessor       = new List <string>();

            foreach (ProjectFile CurProject in GeneratedProjectFiles)
            {
                CodeLiteProject Project = CurProject as CodeLiteProject;
                if (Project == null)
                {
                    continue;
                }

                foreach (string CurrentPath in Project.IntelliSenseIncludeSearchPaths)
                {
                    // Convert relative path into absolute.
                    DirectoryReference IntelliSenseIncludeSearchPath = DirectoryReference.Combine(Project.ProjectFilePath.Directory, CurrentPath);
                    IncludeDirectories.Add(IntelliSenseIncludeSearchPath.FullName);
                }
                foreach (string CurrentPath in Project.IntelliSenseSystemIncludeSearchPaths)
                {
                    // Convert relative path into absolute.
                    DirectoryReference IntelliSenseSystemIncludeSearchPath = DirectoryReference.Combine(Project.ProjectFilePath.Directory, CurrentPath);
                    IncludeDirectories.Add(IntelliSenseSystemIncludeSearchPath.FullName);
                }

                foreach (string CurDef in Project.IntelliSensePreprocessorDefinitions)
                {
                    if (!PreProcessor.Contains(CurDef))
                    {
                        PreProcessor.Add(CurDef);
                    }
                }
            }

            //
            // Write code completions data into files.
            //
            File.WriteAllLines(FullCodeLiteCodeCompletionFile, IncludeDirectories);
            File.WriteAllLines(FullCodeLiteCodeCompletionPreProcessorFile, PreProcessor);

            //
            // Write CodeLites Workspace
            //
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;

            XElement   CodeLiteWorkspace      = new XElement("CodeLite_Workspace");
            XAttribute CodeLiteWorkspaceName  = new XAttribute("Name", MasterProjectName);
            XAttribute CodeLiteWorkspaceSWTLW = new XAttribute("SWTLW", "Yes");             // This flag will only work in CodeLite version > 8.0. See below

            CodeLiteWorkspace.Add(CodeLiteWorkspaceName);
            CodeLiteWorkspace.Add(CodeLiteWorkspaceSWTLW);

            //
            // ATTN This part will work for the next release of CodeLite. That may
            // be CodeLite version > 8.0. CodeLite 8.0 does not have this functionality.
            // TODO Macros are ignored for now.
            //
            // Write Code Completion folders into the WorkspaceParserPaths section.
            //
            XElement CodeLiteWorkspaceParserPaths = new XElement("WorkspaceParserPaths");

            foreach (string CurrentPath in IncludeDirectories)
            {
                XElement   CodeLiteWorkspaceParserPathInclude = new XElement("Include");
                XAttribute CodeLiteWorkspaceParserPath        = new XAttribute("Path", CurrentPath);
                CodeLiteWorkspaceParserPathInclude.Add(CodeLiteWorkspaceParserPath);
                CodeLiteWorkspaceParserPaths.Add(CodeLiteWorkspaceParserPathInclude);
            }
            CodeLiteWorkspace.Add(CodeLiteWorkspaceParserPaths);

            //
            // Write project file information into CodeLite's workspace file.
            //
            XElement CodeLiteWorkspaceTargetEngine   = null;
            XElement CodeLiteWorkspaceTargetPrograms = null;
            XElement CodeLiteWorkspaceTargetGame     = null;

            foreach (ProjectFile CurProject in AllProjectFiles)
            {
                string ProjectExtension = CurProject.ProjectFilePath.GetExtension();

                //
                // TODO For now ignore C# project files.
                //
                if (ProjectExtension == ".csproj")
                {
                    continue;
                }

                //
                // Iterate through all targets.
                //
                foreach (ProjectTarget CurrentTarget in CurProject.ProjectTargets)
                {
                    string[] tmp = CurrentTarget.ToString().Split('.');
                    string   ProjectTargetFileName = CurProject.ProjectFilePath.Directory.MakeRelativeTo(MasterProjectPath) + "/" + tmp[0] + ProjectExtension;
                    String   ProjectName           = tmp[0];


                    XElement   CodeLiteWorkspaceProject       = new XElement("Project");
                    XAttribute CodeLiteWorkspaceProjectName   = new XAttribute("Name", ProjectName);
                    XAttribute CodeLiteWorkspaceProjectPath   = new XAttribute("Path", ProjectTargetFileName);
                    XAttribute CodeLiteWorkspaceProjectActive = new XAttribute("Active", "No");
                    CodeLiteWorkspaceProject.Add(CodeLiteWorkspaceProjectName);
                    CodeLiteWorkspaceProject.Add(CodeLiteWorkspaceProjectPath);
                    CodeLiteWorkspaceProject.Add(CodeLiteWorkspaceProjectActive);

                    //
                    // For CodeLite 10 we can use virtual folder to group projects.
                    //
                    if (ProjectFileFormat == CodeliteProjectFileFormat.CodeLite10)
                    {
                        if ((CurrentTarget.TargetRules.Type == TargetType.Client) ||
                            (CurrentTarget.TargetRules.Type == TargetType.Server) ||
                            (CurrentTarget.TargetRules.Type == TargetType.Editor) ||
                            (CurrentTarget.TargetRules.Type == TargetType.Game))
                        {
                            if (ProjectName.Equals("UE4Client") ||
                                ProjectName.Equals("UE4Server") ||
                                ProjectName.Equals("UE4Game") ||
                                ProjectName.Equals("UE4Editor"))
                            {
                                if (CodeLiteWorkspaceTargetEngine == null)
                                {
                                    CodeLiteWorkspaceTargetEngine = new XElement("VirtualDirectory");
                                    XAttribute CodeLiteWorkspaceTargetEngineName = new XAttribute("Name", "Engine");
                                    CodeLiteWorkspaceTargetEngine.Add(CodeLiteWorkspaceTargetEngineName);
                                }
                                CodeLiteWorkspaceTargetEngine.Add(CodeLiteWorkspaceProject);
                            }
                            else
                            {
                                if (CodeLiteWorkspaceTargetGame == null)
                                {
                                    CodeLiteWorkspaceTargetGame = new XElement("VirtualDirectory");
                                    XAttribute CodeLiteWorkspaceTargetGameName = new XAttribute("Name", "Game");
                                    CodeLiteWorkspaceTargetGame.Add(CodeLiteWorkspaceTargetGameName);
                                }
                                CodeLiteWorkspaceTargetGame.Add(CodeLiteWorkspaceProject);
                            }
                        }
                        else if (CurrentTarget.TargetRules.Type == TargetType.Program)
                        {
                            if (CodeLiteWorkspaceTargetPrograms == null)
                            {
                                CodeLiteWorkspaceTargetPrograms = new XElement("VirtualDirectory");
                                XAttribute CodeLiteWorkspaceTargetProgramsName = new XAttribute("Name", "Programs");
                                CodeLiteWorkspaceTargetPrograms.Add(CodeLiteWorkspaceTargetProgramsName);
                            }
                            CodeLiteWorkspaceTargetPrograms.Add(CodeLiteWorkspaceProject);
                        }
                    }
                    else if (ProjectFileFormat == CodeliteProjectFileFormat.CodeLite9)
                    {
                        CodeLiteWorkspace.Add(CodeLiteWorkspaceProject);
                    }
                }
            }
            if (ProjectFileFormat == CodeliteProjectFileFormat.CodeLite10)
            {
                if (CodeLiteWorkspaceTargetEngine != null)
                {
                    CodeLiteWorkspace.Add(CodeLiteWorkspaceTargetEngine);
                }
                if (CodeLiteWorkspaceTargetPrograms != null)
                {
                    CodeLiteWorkspace.Add(CodeLiteWorkspaceTargetPrograms);
                }
                if (CodeLiteWorkspaceTargetGame != null)
                {
                    CodeLiteWorkspace.Add(CodeLiteWorkspaceTargetGame);
                }
            }
            //
            // We need to create the configuration matrix. That will assign the project configuration to
            // the samge workspace configuration.
            //
            XElement CodeLiteWorkspaceBuildMatrix = new XElement("BuildMatrix");

            foreach (UnrealTargetConfiguration CurConfiguration in SupportedConfigurations)
            {
                if (InstalledPlatformInfo.IsValidConfiguration(CurConfiguration, EProjectType.Code))
                {
                    XElement   CodeLiteWorkspaceBuildMatrixConfiguration = new XElement("WorkspaceConfiguration");
                    XAttribute CodeLiteWorkspaceProjectName     = new XAttribute("Name", CurConfiguration.ToString());
                    XAttribute CodeLiteWorkspaceProjectSelected = new XAttribute("Selected", "no");
                    CodeLiteWorkspaceBuildMatrixConfiguration.Add(CodeLiteWorkspaceProjectName);
                    CodeLiteWorkspaceBuildMatrixConfiguration.Add(CodeLiteWorkspaceProjectSelected);

                    foreach (ProjectFile CurProject in AllProjectFiles)
                    {
                        string ProjectExtension = CurProject.ProjectFilePath.GetExtension();

                        //
                        // TODO For now ignore C# project files.
                        //
                        if (ProjectExtension == ".csproj")
                        {
                            continue;
                        }

                        foreach (ProjectTarget target in CurProject.ProjectTargets)
                        {
                            string[] tmp         = target.ToString().Split('.');
                            String   ProjectName = tmp[0];

                            XElement   CodeLiteWorkspaceBuildMatrixConfigurationProject           = new XElement("Project");
                            XAttribute CodeLiteWorkspaceBuildMatrixConfigurationProjectName       = new XAttribute("Name", ProjectName);
                            XAttribute CodeLiteWorkspaceBuildMatrixConfigurationProjectConfigName = new XAttribute("ConfigName", CurConfiguration.ToString());
                            CodeLiteWorkspaceBuildMatrixConfigurationProject.Add(CodeLiteWorkspaceBuildMatrixConfigurationProjectName);
                            CodeLiteWorkspaceBuildMatrixConfigurationProject.Add(CodeLiteWorkspaceBuildMatrixConfigurationProjectConfigName);
                            CodeLiteWorkspaceBuildMatrixConfiguration.Add(CodeLiteWorkspaceBuildMatrixConfigurationProject);
                        }
                    }
                    CodeLiteWorkspaceBuildMatrix.Add(CodeLiteWorkspaceBuildMatrixConfiguration);
                }
            }

            CodeLiteWorkspace.Add(CodeLiteWorkspaceBuildMatrix);
            CodeLiteWorkspace.Save(FullCodeLiteMasterFile);

            return(true);
        }
Ejemplo n.º 2
0
        protected override bool WriteMasterProjectFile(ProjectFile UBTProject)
        {
            var SolutionFileName               = MasterProjectName + SolutionExtension;
            var CodeCompletionFile             = MasterProjectName + CodeCompletionFileName;
            var CodeCompletionPreProcessorFile = MasterProjectName + CodeCompletionPreProcessorFileName;

            var FullCodeLiteMasterFile                     = Path.Combine(MasterProjectRelativePath, SolutionFileName);
            var FullCodeLiteCodeCompletionFile             = Path.Combine(MasterProjectRelativePath, CodeCompletionFile);
            var FullCodeLiteCodeCompletionPreProcessorFile = Path.Combine(MasterProjectRelativePath, CodeCompletionPreProcessorFile);

            //
            // HACK
            // TODO This is for now a hack. According to the original submitter, Eranif (a CodeLite developer) will support code completion folders in *.workspace files.
            // We create a seperate file with all the folder name in it to copy manually into the code completion
            // filed of CodeLite workspace. (Workspace Settings/Code Completion -> copy the content of the file threre.)
            List <string> IncludeDirectories = new List <string>();
            List <string> PreProcessor       = new List <string>();

            foreach (var CurProject in GeneratedProjectFiles)
            {
                CodeLiteProject Project = CurProject as CodeLiteProject;
                if (Project == null)
                {
                    continue;
                }

                foreach (var CurrentPath in Project.IntelliSenseIncludeSearchPaths)
                {
                    // Convert relative path into abosulte.
                    string IntelliSenseIncludeSearchPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(Project.ProjectFilePath)), CurrentPath));
                    IncludeDirectories.Add(IntelliSenseIncludeSearchPath);
                }
                foreach (var CurrentPath in Project.IntelliSenseSystemIncludeSearchPaths)
                {
                    // Convert relative path into abosulte.
                    string IntelliSenseSystemIncludeSearchPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(Project.ProjectFilePath)), CurrentPath));
                    IncludeDirectories.Add(IntelliSenseSystemIncludeSearchPath);
                }

                foreach (var CurDef in Project.IntelliSensePreprocessorDefinitions)
                {
                    if (!PreProcessor.Contains(CurDef))
                    {
                        PreProcessor.Add(CurDef);
                    }
                }
            }

            //
            // Write code completions data into files.
            //
            File.WriteAllLines(FullCodeLiteCodeCompletionFile, IncludeDirectories);
            File.WriteAllLines(FullCodeLiteCodeCompletionPreProcessorFile, PreProcessor);

            //
            // Write CodeLites Workspace
            //
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;

            XElement   CodeLiteWorkspace      = new XElement("CodeLite_Workspace");
            XAttribute CodeLiteWorkspaceName  = new XAttribute("Name", MasterProjectName);
            XAttribute CodeLiteWorkspaceSWTLW = new XAttribute("SWTLW", "Yes");             // This flag will only work in CodeLite version > 8.0. See below

            CodeLiteWorkspace.Add(CodeLiteWorkspaceName);
            CodeLiteWorkspace.Add(CodeLiteWorkspaceSWTLW);

            //
            // ATTN This part will work for the next release of CodeLite. That may
            // be CodeLite version > 8.0. CodeLite 8.0 does not have this functionality.
            // TODO Macros are ignored for now.
            //
            // Write Code Completion folders into the WorkspaceParserPaths section.
            //
            XElement CodeLiteWorkspaceParserPaths = new XElement("WorkspaceParserPaths");

            foreach (var CurrentPath in IncludeDirectories)
            {
                XElement   CodeLiteWorkspaceParserPathInclude = new XElement("Include");
                XAttribute CodeLiteWorkspaceParserPath        = new XAttribute("Path", CurrentPath);
                CodeLiteWorkspaceParserPathInclude.Add(CodeLiteWorkspaceParserPath);
                CodeLiteWorkspaceParserPaths.Add(CodeLiteWorkspaceParserPathInclude);
            }
            CodeLiteWorkspace.Add(CodeLiteWorkspaceParserPaths);

            //
            // Write project file information into CodeLite's workspace file.
            //
            foreach (var CurProject in AllProjectFiles)
            {
                var ProjectExtension = Path.GetExtension(CurProject.ProjectFilePath);

                //
                // TODO For now ignore C# project files.
                //
                if (ProjectExtension == ".csproj")
                {
                    continue;
                }

                //
                // Iterate through all targets.
                //
                foreach (ProjectTarget CurrentTarget in CurProject.ProjectTargets)
                {
                    string[] tmp = CurrentTarget.ToString().Split('.');
                    string   ProjectTargetFileName = Path.GetDirectoryName(CurProject.RelativeProjectFilePath) + "/" + tmp [0] + ProjectExtension;
                    String   ProjectName           = tmp [0];


                    XElement   CodeLiteWorkspaceProject       = new XElement("Project");
                    XAttribute CodeLiteWorkspaceProjectName   = new XAttribute("Name", ProjectName);
                    XAttribute CodeLiteWorkspaceProjectPath   = new XAttribute("Path", ProjectTargetFileName);
                    XAttribute CodeLiteWorkspaceProjectActive = new XAttribute("Active", "No");
                    CodeLiteWorkspaceProject.Add(CodeLiteWorkspaceProjectName);
                    CodeLiteWorkspaceProject.Add(CodeLiteWorkspaceProjectPath);
                    CodeLiteWorkspaceProject.Add(CodeLiteWorkspaceProjectActive);
                    CodeLiteWorkspace.Add(CodeLiteWorkspaceProject);
                }
            }

            //
            // We need to create the configuration matrix. That will assign the project configuration to
            // the samge workspace configuration.
            //
            XElement CodeLiteWorkspaceBuildMatrix = new XElement("BuildMatrix");

            foreach (UnrealTargetConfiguration CurConfiguration in SupportedConfigurations)
            {
                if (UnrealBuildTool.IsValidConfiguration(CurConfiguration))
                {
                    XElement   CodeLiteWorkspaceBuildMatrixConfiguration = new XElement("WorkspaceConfiguration");
                    XAttribute CodeLiteWorkspaceProjectName     = new XAttribute("Name", CurConfiguration.ToString());
                    XAttribute CodeLiteWorkspaceProjectSelected = new XAttribute("Selected", "no");
                    CodeLiteWorkspaceBuildMatrixConfiguration.Add(CodeLiteWorkspaceProjectName);
                    CodeLiteWorkspaceBuildMatrixConfiguration.Add(CodeLiteWorkspaceProjectSelected);

                    foreach (var CurProject in AllProjectFiles)
                    {
                        var ProjectExtension = Path.GetExtension(CurProject.ProjectFilePath);

                        //
                        // TODO For now ignore C# project files.
                        //
                        if (ProjectExtension == ".csproj")
                        {
                            continue;
                        }

                        foreach (ProjectTarget target in CurProject.ProjectTargets)
                        {
                            string[] tmp         = target.ToString().Split('.');
                            String   ProjectName = tmp [0];

                            XElement   CodeLiteWorkspaceBuildMatrixConfigurationProject           = new XElement("Project");
                            XAttribute CodeLiteWorkspaceBuildMatrixConfigurationProjectName       = new XAttribute("Name", ProjectName);
                            XAttribute CodeLiteWorkspaceBuildMatrixConfigurationProjectConfigName = new XAttribute("ConfigName", CurConfiguration.ToString());
                            CodeLiteWorkspaceBuildMatrixConfigurationProject.Add(CodeLiteWorkspaceBuildMatrixConfigurationProjectName);
                            CodeLiteWorkspaceBuildMatrixConfigurationProject.Add(CodeLiteWorkspaceBuildMatrixConfigurationProjectConfigName);
                            CodeLiteWorkspaceBuildMatrixConfiguration.Add(CodeLiteWorkspaceBuildMatrixConfigurationProject);
                        }
                    }
                    CodeLiteWorkspaceBuildMatrix.Add(CodeLiteWorkspaceBuildMatrixConfiguration);
                }
            }

            CodeLiteWorkspace.Add(CodeLiteWorkspaceBuildMatrix);
            CodeLiteWorkspace.Save(FullCodeLiteMasterFile);

            return(true);
        }