cmExtraCodeLiteGenerator: port to cmXMLWriter
This commit is contained in:
parent
27e0976453
commit
dcdc270eeb
|
@ -24,7 +24,7 @@
|
||||||
#include <cmsys/SystemInformation.hxx>
|
#include <cmsys/SystemInformation.hxx>
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmXMLSafe.h"
|
#include "cmXMLWriter.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry,
|
void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry,
|
||||||
|
@ -54,16 +54,14 @@ void cmExtraCodeLiteGenerator::Generate()
|
||||||
std::string workspaceOutputDir;
|
std::string workspaceOutputDir;
|
||||||
std::string workspaceFileName;
|
std::string workspaceFileName;
|
||||||
std::string workspaceSourcePath;
|
std::string workspaceSourcePath;
|
||||||
std::string lprjdebug;
|
|
||||||
|
|
||||||
cmGeneratedFileStream fout;
|
const std::map<std::string, std::vector<cmLocalGenerator*> >& projectMap =
|
||||||
|
this->GlobalGenerator->GetProjectMap();
|
||||||
|
|
||||||
// loop projects and locate the root project.
|
// loop projects and locate the root project.
|
||||||
// and extract the information for creating the worspace
|
// and extract the information for creating the worspace
|
||||||
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
||||||
it = this->GlobalGenerator->GetProjectMap().begin();
|
it = projectMap.begin(); it!= projectMap.end(); ++it)
|
||||||
it!= this->GlobalGenerator->GetProjectMap().end();
|
|
||||||
++it)
|
|
||||||
{
|
{
|
||||||
const cmMakefile* mf =it->second[0]->GetMakefile();
|
const cmMakefile* mf =it->second[0]->GetMakefile();
|
||||||
this->ConfigName = GetConfigurationName( mf );
|
this->ConfigName = GetConfigurationName( mf );
|
||||||
|
@ -77,18 +75,20 @@ void cmExtraCodeLiteGenerator::Generate()
|
||||||
workspaceFileName = workspaceOutputDir+"/";
|
workspaceFileName = workspaceOutputDir+"/";
|
||||||
workspaceFileName += workspaceProjectName + ".workspace";
|
workspaceFileName += workspaceProjectName + ".workspace";
|
||||||
this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();;
|
this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();;
|
||||||
|
break;
|
||||||
fout.Open(workspaceFileName.c_str(), false, false);
|
|
||||||
fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
|
||||||
"<CodeLite_Workspace Name=\"" << workspaceProjectName << "\" >\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmGeneratedFileStream fout(workspaceFileName.c_str());
|
||||||
|
cmXMLWriter xml(fout);
|
||||||
|
|
||||||
|
xml.StartDocument("utf-8");
|
||||||
|
xml.StartElement("CodeLite_Workspace");
|
||||||
|
xml.Attribute("Name", workspaceProjectName);
|
||||||
|
|
||||||
// for each sub project in the workspace create a codelite project
|
// for each sub project in the workspace create a codelite project
|
||||||
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
||||||
it = this->GlobalGenerator->GetProjectMap().begin();
|
it = projectMap.begin(); it!= projectMap.end(); ++it)
|
||||||
it!= this->GlobalGenerator->GetProjectMap().end();
|
|
||||||
++it)
|
|
||||||
{
|
{
|
||||||
// retrive project information
|
// retrive project information
|
||||||
std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
|
std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
|
||||||
|
@ -101,19 +101,33 @@ void cmExtraCodeLiteGenerator::Generate()
|
||||||
|
|
||||||
// create a project file
|
// create a project file
|
||||||
this->CreateProjectFile(it->second);
|
this->CreateProjectFile(it->second);
|
||||||
fout << " <Project Name=\"" << projectName << "\" Path=\""
|
xml.StartElement("Project");
|
||||||
<< filename << "\" Active=\"No\"/>\n";
|
xml.Attribute("Name", projectName);
|
||||||
lprjdebug += "<Project Name=\"" + projectName
|
xml.Attribute("Path", filename);
|
||||||
+ "\" ConfigName=\"" + this->ConfigName + "\"/>\n";
|
xml.Attribute("Active", "No");
|
||||||
|
xml.EndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
fout << " <BuildMatrix>\n"
|
xml.StartElement("BuildMatrix");
|
||||||
" <WorkspaceConfiguration Name=\""
|
xml.StartElement("WorkspaceConfiguration");
|
||||||
<< this->ConfigName << "\" Selected=\"yes\">\n"
|
xml.Attribute("Name", this->ConfigName);
|
||||||
" " << lprjdebug << ""
|
xml.Attribute("Selected", "yes");
|
||||||
" </WorkspaceConfiguration>\n"
|
|
||||||
" </BuildMatrix>\n"
|
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
||||||
"</CodeLite_Workspace>\n";
|
it = projectMap.begin(); it!= projectMap.end(); ++it)
|
||||||
|
{
|
||||||
|
// retrive project information
|
||||||
|
std::string projectName = it->second[0]->GetProjectName();
|
||||||
|
|
||||||
|
xml.StartElement("Project");
|
||||||
|
xml.Attribute("Name", projectName);
|
||||||
|
xml.Attribute("ConfigName", this->ConfigName);
|
||||||
|
xml.EndElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
xml.EndElement(); // WorkspaceConfiguration
|
||||||
|
xml.EndElement(); // BuildMatrix
|
||||||
|
xml.EndElement(); // CodeLite_Workspace
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create the project file */
|
/* create the project file */
|
||||||
|
@ -138,11 +152,13 @@ void cmExtraCodeLiteGenerator
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
cmXMLWriter xml(fout);
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
xml.StartDocument("utf-8");
|
||||||
"<CodeLite_Project Name=\"" << lgs[0]->GetProjectName()
|
xml.StartElement("CodeLite_Project");
|
||||||
<< "\" InternalType=\"\">\n";
|
xml.Attribute("Name", lgs[0]->GetProjectName());
|
||||||
|
xml.Attribute("InternalType", "");
|
||||||
|
|
||||||
// Collect all used source files in the project
|
// Collect all used source files in the project
|
||||||
// Sort them into two containers, one for C/C++ implementation files
|
// Sort them into two containers, one for C/C++ implementation files
|
||||||
|
@ -285,7 +301,8 @@ void cmExtraCodeLiteGenerator
|
||||||
// Create 2 virtual folders: src and include
|
// Create 2 virtual folders: src and include
|
||||||
// and place all the implementation files into the src
|
// and place all the implementation files into the src
|
||||||
// folder, the rest goes to the include folder
|
// folder, the rest goes to the include folder
|
||||||
fout<< " <VirtualDirectory Name=\"src\">\n";
|
xml.StartElement("VirtualDirectory");
|
||||||
|
xml.Attribute("Name", "src");
|
||||||
|
|
||||||
// insert all source files in the codelite project
|
// insert all source files in the codelite project
|
||||||
// first the C/C++ implementation files, then all others
|
// first the C/C++ implementation files, then all others
|
||||||
|
@ -294,22 +311,25 @@ void cmExtraCodeLiteGenerator
|
||||||
sit!=cFiles.end();
|
sit!=cFiles.end();
|
||||||
++sit)
|
++sit)
|
||||||
{
|
{
|
||||||
std::string relativePath =
|
xml.StartElement("File");
|
||||||
cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str());
|
xml.Attribute("Name",
|
||||||
fout<< " <File Name=\"" << relativePath << "\"/>\n";
|
cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()));
|
||||||
|
xml.EndElement();
|
||||||
}
|
}
|
||||||
fout<< " </VirtualDirectory>\n";
|
xml.EndElement(); // VirtualDirectory
|
||||||
fout<< " <VirtualDirectory Name=\"include\">\n";
|
xml.StartElement("VirtualDirectory");
|
||||||
|
xml.Attribute("Name", "include");
|
||||||
for (std::set<std::string>::const_iterator
|
for (std::set<std::string>::const_iterator
|
||||||
sit=otherFiles.begin();
|
sit=otherFiles.begin();
|
||||||
sit!=otherFiles.end();
|
sit!=otherFiles.end();
|
||||||
++sit)
|
++sit)
|
||||||
{
|
{
|
||||||
std::string relativePath =
|
xml.StartElement("File");
|
||||||
cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str());
|
xml.Attribute("Name",
|
||||||
fout << " <File Name=\"" << relativePath << "\"/>\n";
|
cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()));
|
||||||
|
xml.EndElement();
|
||||||
}
|
}
|
||||||
fout << " </VirtualDirectory>\n";
|
xml.EndElement(); // VirtualDirectory
|
||||||
|
|
||||||
// Get the number of CPUs. We use this information for the make -jN
|
// Get the number of CPUs. We use this information for the make -jN
|
||||||
// command
|
// command
|
||||||
|
@ -319,63 +339,99 @@ void cmExtraCodeLiteGenerator
|
||||||
this->CpuCount = info.GetNumberOfLogicalCPU() *
|
this->CpuCount = info.GetNumberOfLogicalCPU() *
|
||||||
info.GetNumberOfPhysicalCPU();
|
info.GetNumberOfPhysicalCPU();
|
||||||
|
|
||||||
std::string cleanCommand = GetCleanCommand(mf);
|
|
||||||
std::string buildCommand = GetBuildCommand(mf);
|
|
||||||
std::string rebuildCommand = GetRebuildCommand(mf);
|
|
||||||
std::string singleFileCommand = GetSingleFileBuildCommand(mf);
|
|
||||||
|
|
||||||
std::string codeliteCompilerName = this->GetCodeLiteCompilerName(mf);
|
std::string codeliteCompilerName = this->GetCodeLiteCompilerName(mf);
|
||||||
|
|
||||||
fout << "\n"
|
xml.StartElement("Settings");
|
||||||
" <Settings Type=\"" << projectType << "\">\n"
|
xml.Attribute("Type", projectType);
|
||||||
" <Configuration Name=\"" << this->ConfigName << "\" CompilerType=\""
|
|
||||||
<< codeliteCompilerName << "\" DebuggerType=\"GNU gdb debugger\" "
|
xml.StartElement("Configuration");
|
||||||
"Type=\""
|
xml.Attribute("Name", this->ConfigName);
|
||||||
<< projectType << "\" BuildCmpWithGlobalSettings=\"append\" "
|
xml.Attribute("CompilerType", this->GetCodeLiteCompilerName(mf));
|
||||||
"BuildLnkWithGlobalSettings=\"append\" "
|
xml.Attribute("DebuggerType", "GNU gdb debugger");
|
||||||
"BuildResWithGlobalSettings=\"append\">\n"
|
xml.Attribute("Type", projectType);
|
||||||
" <Compiler Options=\"-g\" "
|
xml.Attribute("BuildCmpWithGlobalSettings", "append");
|
||||||
"Required=\"yes\" PreCompiledHeader=\"\">\n"
|
xml.Attribute("BuildLnkWithGlobalSettings", "append");
|
||||||
" <IncludePath Value=\".\"/>\n"
|
xml.Attribute("BuildResWithGlobalSettings", "append");
|
||||||
" </Compiler>\n"
|
|
||||||
" <Linker Options=\"\" Required=\"yes\"/>\n"
|
xml.StartElement("Compiler");
|
||||||
" <ResourceCompiler Options=\"\" Required=\"no\"/>\n"
|
xml.Attribute("Options", "-g");
|
||||||
" <General OutputFile=\"$(IntermediateDirectory)/$(ProjectName)\" "
|
xml.Attribute("Required", "yes");
|
||||||
"IntermediateDirectory=\"./\" Command=\"./$(ProjectName)\" "
|
xml.Attribute("PreCompiledHeader", "");
|
||||||
"CommandArguments=\"\" WorkingDirectory=\"$(IntermediateDirectory)\" "
|
xml.StartElement("IncludePath");
|
||||||
"PauseExecWhenProcTerminates=\"yes\"/>\n"
|
xml.Attribute("Value", ".");
|
||||||
" <Debugger IsRemote=\"no\" RemoteHostName=\"\" "
|
xml.EndElement(); // IncludePath
|
||||||
"RemoteHostPort=\"\" DebuggerPath=\"\">\n"
|
xml.EndElement(); // Compiler
|
||||||
" <PostConnectCommands/>\n"
|
|
||||||
" <StartupCommands/>\n"
|
xml.StartElement("Linker");
|
||||||
" </Debugger>\n"
|
xml.Attribute("Options", "");
|
||||||
" <PreBuild/>\n"
|
xml.Attribute("Required", "yes");
|
||||||
" <PostBuild/>\n"
|
xml.EndElement(); // Linker
|
||||||
" <CustomBuild Enabled=\"yes\">\n"
|
|
||||||
" <RebuildCommand>" << rebuildCommand << "</RebuildCommand>\n"
|
xml.StartElement("ResourceCompiler");
|
||||||
" <CleanCommand>" << cleanCommand << "</CleanCommand>\n"
|
xml.Attribute("Options", "");
|
||||||
" <BuildCommand>" << buildCommand << "</BuildCommand>\n"
|
xml.Attribute("Required", "no");
|
||||||
" <SingleFileCommand>" << singleFileCommand
|
xml.EndElement(); // ResourceCompiler
|
||||||
<< "</SingleFileCommand>\n"
|
|
||||||
" <PreprocessFileCommand/>\n"
|
xml.StartElement("General");
|
||||||
" <WorkingDirectory>$(WorkspacePath)</WorkingDirectory>\n"
|
xml.Attribute("OutputFile", "$(IntermediateDirectory)/$(ProjectName)");
|
||||||
" </CustomBuild>\n"
|
xml.Attribute("IntermediateDirectory", "./");
|
||||||
" <AdditionalRules>\n"
|
xml.Attribute("Command", "./$(ProjectName)");
|
||||||
" <CustomPostBuild/>\n"
|
xml.Attribute("CommandArguments", "");
|
||||||
" <CustomPreBuild/>\n"
|
xml.Attribute("WorkingDirectory", "$(IntermediateDirectory)");
|
||||||
" </AdditionalRules>\n"
|
xml.Attribute("PauseExecWhenProcTerminates", "yes");
|
||||||
" </Configuration>\n"
|
xml.EndElement(); // General
|
||||||
" <GlobalSettings>\n"
|
|
||||||
" <Compiler Options=\"\">\n"
|
xml.StartElement("Debugger");
|
||||||
" <IncludePath Value=\".\"/>\n"
|
xml.Attribute("IsRemote", "no");
|
||||||
" </Compiler>\n"
|
xml.Attribute("RemoteHostName", "");
|
||||||
" <Linker Options=\"\">\n"
|
xml.Attribute("RemoteHostPort", "");
|
||||||
" <LibraryPath Value=\".\"/>\n"
|
xml.Attribute("DebuggerPath", "");
|
||||||
" </Linker>\n"
|
xml.Element("PostConnectCommands");
|
||||||
" <ResourceCompiler Options=\"\"/>\n"
|
xml.Element("StartupCommands");
|
||||||
" </GlobalSettings>\n"
|
xml.EndElement(); // Debugger
|
||||||
" </Settings>\n"
|
|
||||||
"</CodeLite_Project>\n";
|
xml.Element("PreBuild");
|
||||||
|
xml.Element("PostBuild");
|
||||||
|
|
||||||
|
xml.StartElement("CustomBuild");
|
||||||
|
xml.Attribute("Enabled", "yes");
|
||||||
|
xml.Element("RebuildCommand", GetRebuildCommand(mf));
|
||||||
|
xml.Element("CleanCommand", GetCleanCommand(mf));
|
||||||
|
xml.Element("BuildCommand", GetBuildCommand(mf));
|
||||||
|
xml.Element("SingleFileCommand", GetSingleFileBuildCommand(mf));
|
||||||
|
xml.Element("PreprocessFileCommand");
|
||||||
|
xml.Element("WorkingDirectory", "$(WorkspacePath)");
|
||||||
|
xml.EndElement(); // CustomBuild
|
||||||
|
|
||||||
|
xml.StartElement("AdditionalRules");
|
||||||
|
xml.Element("CustomPostBuild");
|
||||||
|
xml.Element("CustomPreBuild");
|
||||||
|
xml.EndElement(); // AdditionalRules
|
||||||
|
|
||||||
|
xml.EndElement(); // Configuration
|
||||||
|
xml.StartElement("GlobalSettings");
|
||||||
|
|
||||||
|
xml.StartElement("Compiler");
|
||||||
|
xml.Attribute("Options", "");
|
||||||
|
xml.StartElement("IncludePath");
|
||||||
|
xml.Attribute("Value", ".");
|
||||||
|
xml.EndElement(); // IncludePath
|
||||||
|
xml.EndElement(); // Compiler
|
||||||
|
|
||||||
|
xml.StartElement("Linker");
|
||||||
|
xml.Attribute("Options", "");
|
||||||
|
xml.StartElement("LibraryPath");
|
||||||
|
xml.Attribute("Value", ".");
|
||||||
|
xml.EndElement(); // LibraryPath
|
||||||
|
xml.EndElement(); // Linker
|
||||||
|
|
||||||
|
xml.StartElement("ResourceCompiler");
|
||||||
|
xml.Attribute("Options", "");
|
||||||
|
xml.EndElement(); // ResourceCompiler
|
||||||
|
|
||||||
|
xml.EndElement(); // GlobalSettings
|
||||||
|
xml.EndElement(); // Settings
|
||||||
|
xml.EndElement(); // CodeLite_Project
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -454,7 +510,7 @@ cmExtraCodeLiteGenerator::GetCleanCommand(const cmMakefile* mf) const
|
||||||
std::string
|
std::string
|
||||||
cmExtraCodeLiteGenerator::GetRebuildCommand(const cmMakefile* mf) const
|
cmExtraCodeLiteGenerator::GetRebuildCommand(const cmMakefile* mf) const
|
||||||
{
|
{
|
||||||
return GetCleanCommand(mf) + cmXMLSafe(" && ").str() + GetBuildCommand(mf);
|
return GetCleanCommand(mf) + " && " + GetBuildCommand(mf);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
|
Loading…
Reference in New Issue