Merge topic 'use-cmXMLWriter'

51465da1 CPack/IFW: port to cmXMLWriter
754485af cmExtraEclipseCDT4Generator: port to cmXMLWriter
c45671b0 cmGlobalKdevelopGenerator: port to cmXMLWriter
dcdc270e cmExtraCodeLiteGenerator: port to cmXMLWriter
27e09764 cmExtraCodeBlocksGenerator: port to cmXMLWriter
d7407621 cmXMLWriter: add Doctype() method
dd27e313 cmXMLWriter: overload Element() method for empty elements
This commit is contained in:
Brad King 2016-03-23 11:19:19 -04:00 committed by CMake Topic Stage
commit 405766757c
14 changed files with 920 additions and 805 deletions

View File

@ -27,7 +27,7 @@
#include <cmSystemTools.h>
#include <cmMakefile.h>
#include <cmGeneratedFileStream.h>
#include <cmXMLSafe.h>
#include <cmXMLWriter.h>
#include <cmVersionConfig.h>
#include <cmTimestamp.h>
@ -611,18 +611,19 @@ cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
}
//----------------------------------------------------------------------------
void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter &xout)
{
xout << "<!-- Generated by CPack " << CMake_VERSION << " IFW generator "
std::stringstream comment;
comment << "Generated by CPack " << CMake_VERSION << " IFW generator "
<< "for QtIFW ";
if(IsVersionLess("2.0"))
{
xout << "less 2.0";
comment << "less 2.0";
}
else
{
xout << FrameworkVersion;
comment << FrameworkVersion;
}
xout << " tools at " << cmTimestamp().CurrentTime("", true) << " -->"
<< std::endl;
comment << " tools at " << cmTimestamp().CurrentTime("", true);
xout.Comment(comment.str().c_str());
}

View File

@ -13,12 +13,13 @@
#ifndef cmCPackIFWGenerator_h
#define cmCPackIFWGenerator_h
#include <cmGeneratedFileStream.h>
#include <CPack/cmCPackGenerator.h>
#include "cmCPackIFWPackage.h"
#include "cmCPackIFWInstaller.h"
class cmXMLWriter;
/** \class cmCPackIFWGenerator
* \brief A generator for Qt Installer Framework tools
*
@ -121,7 +122,7 @@ protected: // Methods
cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup *group) const;
cmCPackIFWPackage* GetComponentPackage(cmCPackComponent *component) const;
void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
void WriteGeneratedByToStrim(cmXMLWriter& xout);
protected: // Data

View File

@ -17,7 +17,7 @@
#include <CPack/cmCPackLog.h>
#include <cmGeneratedFileStream.h>
#include <cmXMLSafe.h>
#include <cmXMLWriter.h>
#ifdef cmCPackLogger
# undef cmCPackLogger
@ -334,30 +334,27 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
}
// Output stream
cmGeneratedFileStream xout((Directory + "/config/config.xml").data());
cmGeneratedFileStream fout((Directory + "/config/config.xml").data());
cmXMLWriter xout(fout);
xout << "<?xml version=\"1.0\"?>" << std::endl;
xout.StartDocument();
WriteGeneratedByToStrim(xout);
xout << "<Installer>" << std::endl;
xout.StartElement("Installer");
xout << " <Name>" << cmXMLSafe(Name).str() << "</Name>" << std::endl;
xout << " <Version>" << Version << "</Version>" << std::endl;
xout << " <Title>" << cmXMLSafe(Title).str() << "</Title>"
<< std::endl;
xout.Element("Name", Name);
xout.Element("Version", Version);
xout.Element("Title", Title);
if(!Publisher.empty())
{
xout << " <Publisher>" << cmXMLSafe(Publisher).str()
<< "</Publisher>" << std::endl;
xout.Element("Publisher", Publisher);
}
if(!ProductUrl.empty())
{
xout << " <ProductUrl>" << ProductUrl << "</ProductUrl>" << std::endl;
xout.Element("ProductUrl", ProductUrl);
}
// ApplicationIcon
@ -369,8 +366,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
name = cmSystemTools::GetFilenameWithoutExtension(name);
cmsys::SystemTools::CopyFileIfDifferent(
InstallerApplicationIcon.data(), path.data());
xout << " <InstallerApplicationIcon>" << name
<< "</InstallerApplicationIcon>" << std::endl;
xout.Element("InstallerApplicationIcon", name);
}
// WindowIcon
@ -380,8 +376,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(
InstallerWindowIcon.data(), path.data());
xout << " <InstallerWindowIcon>" << name
<< "</InstallerWindowIcon>" << std::endl;
xout.Element("InstallerWindowIcon", name);
}
// Logo
@ -390,104 +385,91 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string name = cmSystemTools::GetFilenameName(Logo);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data());
xout << " <Logo>" << name << "</Logo>" << std::endl;
xout.Element("Logo", name);
}
// Start menu
if(!IsVersionLess("2.0"))
{
xout << " <StartMenuDir>" << StartMenuDir
<< "</StartMenuDir>" << std::endl;
xout.Element("StartMenuDir", StartMenuDir);
}
// Target dir
if(!TargetDir.empty())
{
xout << " <TargetDir>" << TargetDir << "</TargetDir>" << std::endl;
xout.Element("TargetDir", TargetDir);
}
// Admin target dir
if(!AdminTargetDir.empty())
{
xout << " <AdminTargetDir>" << AdminTargetDir
<< "</AdminTargetDir>" << std::endl;
xout.Element("AdminTargetDir", AdminTargetDir);
}
// Remote repositories
if (!Repositories.empty())
{
xout << " <RemoteRepositories>" << std::endl;
xout.StartElement("RemoteRepositories");
for(std::vector<RepositoryStruct>::iterator
rit = Repositories.begin(); rit != Repositories.end(); ++rit)
{
xout << " <Repository>" << std::endl;
xout.StartElement("Repository");
// Url
xout << " <Url>" << rit->Url
<< "</Url>" << std::endl;
xout.Element("Url", rit->Url);
// Enabled
if(!rit->Enabled.empty())
{
xout << " <Enabled>" << rit->Enabled
<< "</Enabled>" << std::endl;
xout.Element("Enabled", rit->Enabled);
}
// Username
if(!rit->Username.empty())
{
xout << " <Username>" << rit->Username
<< "</Username>" << std::endl;
xout.Element("Username", rit->Username);
}
// Password
if(!rit->Password.empty())
{
xout << " <Password>" << rit->Password
<< "</Password>" << std::endl;
xout.Element("Password", rit->Password);
}
// DisplayName
if(!rit->DisplayName.empty())
{
xout << " <DisplayName>" << rit->DisplayName
<< "</DisplayName>" << std::endl;
xout.Element("DisplayName", rit->DisplayName);
}
xout << " </Repository>" << std::endl;
xout.EndElement();
}
xout << " </RemoteRepositories>" << std::endl;
xout.EndElement();
}
// Maintenance tool
if(!IsVersionLess("2.0") && !MaintenanceToolName.empty())
{
xout << " <MaintenanceToolName>" << MaintenanceToolName
<< "</MaintenanceToolName>" << std::endl;
xout.Element("MaintenanceToolName", MaintenanceToolName);
}
// Maintenance tool ini file
if(!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty())
{
xout << " <MaintenanceToolIniFile>" << MaintenanceToolIniFile
<< "</MaintenanceToolIniFile>" << std::endl;
xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile);
}
// Different allows
if(IsVersionLess("2.0"))
{
// CPack IFW default policy
xout << " <!-- CPack IFW default policy for QtIFW less 2.0 -->"
<< std::endl;
xout << " <AllowNonAsciiCharacters>true</AllowNonAsciiCharacters>"
<< std::endl;
xout << " <AllowSpaceInPath>true</AllowSpaceInPath>" << std::endl;
xout.Comment("CPack IFW default policy for QtIFW less 2.0");
xout.Element("AllowNonAsciiCharacters", "true");
xout.Element("AllowSpaceInPath", "true");
}
else
{
if(!AllowNonAsciiCharacters.empty())
{
xout << " <AllowNonAsciiCharacters>" << AllowNonAsciiCharacters
<< "</AllowNonAsciiCharacters>" << std::endl;
xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters);
}
if(!AllowSpaceInPath.empty())
{
xout << " <AllowAllowSpaceInPath>" << AllowSpaceInPath
<< "</AllowSpaceInPath>" << std::endl;
xout.Element("AllowSpaceInPath", AllowSpaceInPath);
}
}
@ -497,10 +479,11 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string name = cmSystemTools::GetFilenameName(ControlScript);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data());
xout << " <ControlScript>" << name << "</ControlScript>" << std::endl;
xout.Element("ControlScript", name);
}
xout << "</Installer>" << std::endl;
xout.EndElement();
xout.EndDocument();
}
//----------------------------------------------------------------------------
@ -535,7 +518,7 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
}
}
void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter &xout)
{
if(Generator) Generator->WriteGeneratedByToStrim(xout);
}

View File

@ -13,11 +13,11 @@
#ifndef cmCPackIFWInstaller_h
#define cmCPackIFWInstaller_h
#include <cmGeneratedFileStream.h>
#include <cmStandardIncludes.h>
class cmCPackIFWPackage;
class cmCPackIFWGenerator;
class cmXMLWriter;
/** \class cmCPackIFWInstaller
* \brief A binary installer to be created CPack IFW generator
@ -115,7 +115,7 @@ public: // Internal implementation
std::string Directory;
protected:
void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
void WriteGeneratedByToStrim(cmXMLWriter& xout);
};
#endif // cmCPackIFWInstaller_h

View File

@ -18,6 +18,7 @@
#include <cmGeneratedFileStream.h>
#include <cmTimestamp.h>
#include <cmXMLWriter.h>
//----------------------------------------------------------------- Logger ---
#ifdef cmCPackLogger
@ -447,35 +448,28 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
// Output stream
cmGeneratedFileStream xout((Directory + "/meta/package.xml").data());
cmGeneratedFileStream fout((Directory + "/meta/package.xml").data());
cmXMLWriter xout(fout);
xout << "<?xml version=\"1.0\"?>" << std::endl;
xout.StartDocument();
WriteGeneratedByToStrim(xout);
xout << "<Package>" << std::endl;
xout.StartElement("Package");
xout << " <DisplayName>" << DisplayName
<< "</DisplayName>" << std::endl;
xout.Element("DisplayName", DisplayName);
xout.Element("Description", Description);
xout.Element("Name", Name);
xout.Element("Version", Version);
xout << " <Description>" << Description
<< "</Description>" << std::endl;
xout << " <Name>" << Name << "</Name>" << std::endl;
xout << " <Version>" << Version
<< "</Version>" << std::endl;
xout << " <ReleaseDate>";
if(ReleaseDate.empty())
if (!ReleaseDate.empty())
{
xout << cmTimestamp().CurrentTime("%Y-%m-%d", true);
xout.Element("ReleaseDate", ReleaseDate);
}
else
{
xout << ReleaseDate;
xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true));
}
xout << "</ReleaseDate>" << std::endl;
// Script (copy to meta dir)
if(!Script.empty())
@ -483,7 +477,7 @@ void cmCPackIFWPackage::GeneratePackageFile()
std::string name = cmSystemTools::GetFilenameName(Script);
std::string path = Directory + "/meta/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data());
xout << " <Script>" << name << "</Script>" << std::endl;
xout.Element("Script", name);
}
// Dependencies
@ -501,16 +495,16 @@ void cmCPackIFWPackage::GeneratePackageFile()
// Write dependencies
if (!compDepSet.empty())
{
xout << " <Dependencies>";
std::stringstream dependencies;
std::set<DependenceStruct>::iterator it = compDepSet.begin();
xout << it->NameWithCompare();
dependencies << it->NameWithCompare();
++it;
while(it != compDepSet.end())
{
xout << "," << it->NameWithCompare();
dependencies << "," << it->NameWithCompare();
++it;
}
xout << "</Dependencies>" << std::endl;
xout.Element("Dependencies", dependencies.str());
}
// Licenses (copy to meta dir)
@ -524,43 +518,42 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
if(!licenses.empty())
{
xout << " <Licenses>" << std::endl;
xout.StartElement("Licenses");
for(size_t i = 0; i < licenses.size(); i += 2)
{
xout << " <License "
<< "name=\"" << licenses[i] << "\" "
<< "file=\"" << licenses[i + 1] << "\" "
<< "/>" <<std::endl;
xout.StartElement("License");
xout.Attribute("name", licenses[i]);
xout.Attribute("file", licenses[i + 1]);
xout.EndElement();
}
xout << " </Licenses>" << std::endl;
xout.EndElement();
}
if (!ForcedInstallation.empty())
{
xout << " <ForcedInstallation>" << ForcedInstallation
<< "</ForcedInstallation>" << std::endl;
xout.Element("ForcedInstallation", ForcedInstallation);
}
if (!Virtual.empty())
{
xout << " <Virtual>" << Virtual << "</Virtual>" << std::endl;
xout.Element("Virtual", Virtual);
}
else if (!Default.empty())
{
xout << " <Default>" << Default << "</Default>" << std::endl;
xout.Element("Default", Default);
}
// Priority
if(!SortingPriority.empty())
{
xout << " <SortingPriority>" << SortingPriority
<< "</SortingPriority>" << std::endl;
xout.Element("SortingPriority", SortingPriority);
}
xout << "</Package>" << std::endl;
xout.EndElement();
xout.EndDocument();
}
void cmCPackIFWPackage::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter &xout)
{
if(Generator) Generator->WriteGeneratedByToStrim(xout);
}

View File

@ -14,12 +14,12 @@
#define cmCPackIFWPackage_h
#include <cmStandardIncludes.h>
#include <cmGeneratedFileStream.h>
class cmCPackComponent;
class cmCPackComponentGroup;
class cmCPackIFWInstaller;
class cmCPackIFWGenerator;
class cmXMLWriter;
/** \class cmCPackIFWPackage
* \brief A single component to be installed by CPack IFW generator
@ -135,7 +135,7 @@ public: // Internal implementation
std::string Directory;
protected:
void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
void WriteGeneratedByToStrim(cmXMLWriter& xout);
};
#endif // cmCPackIFWPackage_h

View File

@ -18,7 +18,7 @@
#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
#include "cmXMLSafe.h"
#include "cmXMLWriter.h"
#include <cmsys/SystemTools.hxx>
@ -101,11 +101,11 @@ struct Tree
void InsertPath(const std::vector<std::string>& splitted,
std::vector<std::string>::size_type start,
const std::string& fileName);
void BuildVirtualFolder(std::string& virtualFolders) const;
void BuildVirtualFolder(cmXMLWriter& xml) const;
void BuildVirtualFolderImpl(std::string& virtualFolders,
const std::string& prefix) const;
void BuildUnit(std::string& unitString, const std::string& fsPath) const;
void BuildUnitImpl(std::string& unitString,
void BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const;
void BuildUnitImpl(cmXMLWriter& xml,
const std::string& virtualFolderPath,
const std::string& fsPath) const;
};
@ -159,16 +159,18 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
}
void Tree::BuildVirtualFolder(std::string& virtualFolders) const
void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
{
virtualFolders += "<Option virtualFolders=\"CMake Files\\;";
xml.StartElement("Option");
std::string virtualFolders = "CMake Files\\;";
for (std::vector<Tree>::const_iterator it = folders.begin();
it != folders.end();
++it)
{
it->BuildVirtualFolderImpl(virtualFolders, "");
}
virtualFolders += "\" />";
xml.Attribute("virtualFolders", virtualFolders);
xml.EndElement();
}
@ -185,26 +187,31 @@ void Tree::BuildVirtualFolderImpl(std::string& virtualFolders,
}
void Tree::BuildUnit(std::string& unitString, const std::string& fsPath) const
void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const
{
for (std::vector<std::string>::const_iterator it = files.begin();
it != files.end();
++it)
{
unitString += " <Unit filename=\"" + fsPath + *it + "\">\n";
unitString += " <Option virtualFolder=\"CMake Files\\\" />\n";
unitString += " </Unit>\n";
xml.StartElement("Unit");
xml.Attribute("filename", fsPath + *it);
xml.StartElement("Option");
xml.Attribute("virtualFolder", "CMake Files\\");
xml.EndElement();
xml.EndElement();
}
for (std::vector<Tree>::const_iterator it = folders.begin();
it != folders.end();
++it)
{
it->BuildUnitImpl(unitString, "", fsPath);
it->BuildUnitImpl(xml, "", fsPath);
}
}
void Tree::BuildUnitImpl(std::string& unitString,
void Tree::BuildUnitImpl(cmXMLWriter& xml,
const std::string& virtualFolderPath,
const std::string& fsPath) const
{
@ -212,16 +219,21 @@ void Tree::BuildUnitImpl(std::string& unitString,
it != files.end();
++it)
{
unitString += " <Unit filename=\"" +fsPath+path+ "/" + *it + "\">\n";
unitString += " <Option virtualFolder=\"CMake Files\\"
+ virtualFolderPath + path + "\\\" />\n";
unitString += " </Unit>\n";
xml.StartElement("Unit");
xml.Attribute("filename", fsPath + path + "/" + *it);
xml.StartElement("Option");
xml.Attribute("virtualFolder",
"CMake Files\\" + virtualFolderPath + path + "\\");
xml.EndElement();
xml.EndElement();
}
for (std::vector<Tree>::const_iterator it = folders.begin();
it != folders.end();
++it)
{
it->BuildUnitImpl(unitString,
it->BuildUnitImpl(xml,
virtualFolderPath + path + "\\", fsPath + path + "/");
}
}
@ -289,30 +301,41 @@ void cmExtraCodeBlocksGenerator
}
}
// Now build a virtual tree string
std::string virtualFolders;
tree.BuildVirtualFolder(virtualFolders);
// And one for <Unit>
std::string unitFiles;
tree.BuildUnit(unitFiles, std::string(lgs[0]->GetSourceDirectory()) + "/");
// figure out the compiler
std::string compiler = this->GetCBCompilerId(mf);
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
const std::string makeArgs = mf->GetSafeDefinition(
"CMAKE_CODEBLOCKS_MAKE_ARGUMENTS");
fout<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"
"<CodeBlocks_project_file>\n"
" <FileVersion major=\"1\" minor=\"6\" />\n"
" <Project>\n"
" <Option title=\"" << lgs[0]->GetProjectName()<<"\" />\n"
" <Option makefile_is_custom=\"1\" />\n"
" <Option compiler=\"" << compiler << "\" />\n"
" "<<virtualFolders<<"\n"
" <Build>\n";
cmXMLWriter xml(fout);
xml.StartDocument();
xml.StartElement("CodeBlocks_project_file");
this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str(),
xml.StartElement("FileVersion");
xml.Attribute("major", 1);
xml.Attribute("minor", 6);
xml.EndElement();
xml.StartElement("Project");
xml.StartElement("Option");
xml.Attribute("title", lgs[0]->GetProjectName());
xml.EndElement();
xml.StartElement("Option");
xml.Attribute("makefile_is_custom", 1);
xml.EndElement();
xml.StartElement("Option");
xml.Attribute("compiler", compiler);
xml.EndElement();
// Now build a virtual tree
tree.BuildVirtualFolder(xml);
xml.StartElement("Build");
this->AppendTarget(xml, "all", 0, make.c_str(), lgs[0], compiler.c_str(),
makeArgs);
// add all executable and library targets and some of the GLOBAL
@ -334,7 +357,7 @@ void cmExtraCodeBlocksGenerator
if (strcmp((*lg)->GetCurrentBinaryDirectory(),
(*lg)->GetBinaryDirectory())==0)
{
this->AppendTarget(fout, targetName, 0,
this->AppendTarget(xml, targetName, 0,
make.c_str(), *lg, compiler.c_str(),
makeArgs);
}
@ -352,7 +375,7 @@ void cmExtraCodeBlocksGenerator
break;
}
this->AppendTarget(fout, targetName, 0,
this->AppendTarget(xml, targetName, 0,
make.c_str(), *lg, compiler.c_str(),makeArgs);
break;
case cmState::EXECUTABLE:
@ -362,11 +385,11 @@ void cmExtraCodeBlocksGenerator
case cmState::OBJECT_LIBRARY:
{
cmGeneratorTarget* gt = *ti;
this->AppendTarget(fout, targetName, gt,
this->AppendTarget(xml, targetName, gt,
make.c_str(), *lg, compiler.c_str(), makeArgs);
std::string fastTarget = targetName;
fastTarget += "/fast";
this->AppendTarget(fout, fastTarget, gt,
this->AppendTarget(xml, fastTarget, gt,
make.c_str(), *lg, compiler.c_str(), makeArgs);
}
break;
@ -376,8 +399,7 @@ void cmExtraCodeBlocksGenerator
}
}
fout<<" </Build>\n";
xml.EndElement(); // Build
// Collect all used source files in the project.
// Keep a list of C/C++ source files which might have an acompanying header
@ -505,24 +527,27 @@ void cmExtraCodeBlocksGenerator
std::string const& unitFilename = sit->first;
CbpUnit const& unit = sit->second;
fout<<" <Unit filename=\""<< cmXMLSafe(unitFilename) <<"\">\n";
xml.StartElement("Unit");
xml.Attribute("filename", unitFilename);
for(std::vector<const cmGeneratorTarget*>::const_iterator ti =
unit.Targets.begin();
ti != unit.Targets.end(); ++ti)
{
std::string const& targetName = (*ti)->GetName();
fout<<" <Option target=\""<< cmXMLSafe(targetName) <<"\"/>\n";
xml.StartElement("Option");
xml.Attribute("target", (*ti)->GetName());
xml.EndElement();
}
fout<<" </Unit>\n";
xml.EndElement();
}
// Add CMakeLists.txt
fout<<unitFiles;
tree.BuildUnit(xml, std::string(mf->GetHomeDirectory()) + "/");
fout<<" </Project>\n"
"</CodeBlocks_project_file>\n";
xml.EndElement(); // Project
xml.EndElement(); // CodeBlocks_project_file
xml.EndDocument();
}
@ -553,7 +578,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target.
void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
void cmExtraCodeBlocksGenerator::AppendTarget(cmXMLWriter& xml,
const std::string& targetName,
cmGeneratorTarget* target,
const char* make,
@ -565,7 +590,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
std::string makefileName = lg->GetCurrentBinaryDirectory();
makefileName += "/Makefile";
fout<<" <Target title=\"" << targetName << "\">\n";
xml.StartElement("Target");
xml.Attribute("title", targetName);
if (target!=0)
{
int cbTargetType = this->GetCBTargetType(target);
@ -603,13 +630,29 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
location = target->GetLocation(buildType);
}
fout<<" <Option output=\"" << location
<< "\" prefix_auto=\"0\" extension_auto=\"0\" />\n"
" <Option working_dir=\"" << workingDir << "\" />\n"
" <Option object_output=\"./\" />\n"
" <Option type=\"" << cbTargetType << "\" />\n"
" <Option compiler=\"" << compiler << "\" />\n"
" <Compiler>\n";
xml.StartElement("Option");
xml.Attribute("output", location);
xml.Attribute("prefix_auto", 0);
xml.Attribute("extension_auto", 0);
xml.EndElement();
xml.StartElement("Option");
xml.Attribute("working_dir", workingDir);
xml.EndElement();
xml.StartElement("Option");
xml.Attribute("object_output", "./");
xml.EndElement();
xml.StartElement("Option");
xml.Attribute("type", cbTargetType);
xml.EndElement();
xml.StartElement("Option");
xml.Attribute("compiler", compiler);
xml.EndElement();
xml.StartElement("Compiler");
// the compilerdefines for this target
std::vector<std::string> cdefs;
@ -619,8 +662,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
for(std::vector<std::string>::const_iterator di = cdefs.begin();
di != cdefs.end(); ++di)
{
cmXMLSafe safedef(di->c_str());
fout <<" <Add option=\"-D" << safedef.str() << "\" />\n";
xml.StartElement("Add");
xml.Attribute("option", "-D" + *di);
xml.EndElement();
}
// the include directories for this target
@ -653,36 +697,48 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
dirIt != uniqIncludeDirs.end();
++dirIt)
{
fout <<" <Add directory=\"" << *dirIt << "\" />\n";
xml.StartElement("Add");
xml.Attribute("directory", *dirIt);
xml.EndElement();
}
fout<<" </Compiler>\n";
xml.EndElement(); // Compiler
}
else // e.g. all and the GLOBAL and UTILITY targets
{
fout<<" <Option working_dir=\""
<< lg->GetCurrentBinaryDirectory() << "\" />\n"
<<" <Option type=\"" << 4 << "\" />\n";
xml.StartElement("Option");
xml.Attribute("working_dir", lg->GetCurrentBinaryDirectory());
xml.EndElement();
xml.StartElement("Option");
xml.Attribute("type", 4);
xml.EndElement();
}
fout<<" <MakeCommands>\n"
" <Build command=\""
<< this->BuildMakeCommand(make, makefileName.c_str(), targetName,
makeFlags)
<< "\" />\n"
" <CompileFile command=\""
<< this->BuildMakeCommand(make, makefileName.c_str(),"&quot;$file&quot;",
makeFlags)
<< "\" />\n"
" <Clean command=\""
<< this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags)
<< "\" />\n"
" <DistClean command=\""
<< this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags)
<< "\" />\n"
" </MakeCommands>\n"
" </Target>\n";
xml.StartElement("MakeCommands");
xml.StartElement("Build");
xml.Attribute("command",
this->BuildMakeCommand(make, makefileName.c_str(), targetName, makeFlags));
xml.EndElement();
xml.StartElement("CompileFile");
xml.Attribute("command",
this->BuildMakeCommand(make, makefileName.c_str(),"\"$file\"", makeFlags));
xml.EndElement();
xml.StartElement("Clean");
xml.Attribute("command",
this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags));
xml.EndElement();
xml.StartElement("DistClean");
xml.Attribute("command",
this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags));
xml.EndElement();
xml.EndElement(); //MakeCommands
xml.EndElement(); //Target
}
@ -825,7 +881,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
// http://public.kitware.com/Bug/view.php?id=13952
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
command += " /NOLOGO /f ";
command += cmXMLSafe(makefileName).str();
command += makefileName;
command += " VERBOSE=1 ";
command += target;
}
@ -834,9 +890,9 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
// no escaping of spaces in this case, see
// http://public.kitware.com/Bug/view.php?id=10014
std::string makefileName = makefile;
command += " -f &quot;";
command += " -f \"";
command += makefileName;
command += "&quot; ";
command += "\" ";
command += " VERBOSE=1 ";
command += target;
}
@ -848,9 +904,9 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
else
{
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
command += " -f &quot;";
command += " -f \"";
command += makefileName;
command += "&quot; ";
command += "\" ";
command += " VERBOSE=1 ";
command += target;
}

View File

@ -18,7 +18,7 @@
class cmLocalGenerator;
class cmMakefile;
class cmGeneratorTarget;
class cmGeneratedFileStream;
class cmXMLWriter;
/** \class cmExtraCodeBlocksGenerator
* \brief Write CodeBlocks project files for Makefile based projects
@ -56,7 +56,7 @@ private:
std::string BuildMakeCommand(const std::string& make, const char* makefile,
const std::string& target,
const std::string& makeFlags);
void AppendTarget(cmGeneratedFileStream& fout,
void AppendTarget(cmXMLWriter& xml,
const std::string& targetName,
cmGeneratorTarget* target,
const char* make,

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@
#include "cmExternalMakefileProjectGenerator.h"
class cmMakefile;
class cmGeneratedFileStream;
class cmXMLWriter;
/** \class cmExtraEclipseCDT4Generator
* \brief Write Eclipse project files for Makefile based projects
@ -67,19 +67,17 @@ private:
const std::string& type,
const std::string& path);
static std::string EscapeForXML(const std::string& value);
// Helper functions
static void AppendStorageScanners(cmGeneratedFileStream& fout,
static void AppendStorageScanners(cmXMLWriter& xml,
const cmMakefile& makefile);
static void AppendTarget (cmGeneratedFileStream& fout,
static void AppendTarget (cmXMLWriter& xml,
const std::string& target,
const std::string& make,
const std::string& makeArguments,
const std::string& path,
const char* prefix = "",
const char* makeTarget = NULL);
static void AppendScannerProfile (cmGeneratedFileStream& fout,
static void AppendScannerProfile (cmXMLWriter& xml,
const std::string& profileID,
bool openActionEnabled,
const std::string& openActionFilePath,
@ -90,21 +88,20 @@ private:
bool runActionUseDefault,
bool sipParserEnabled);
static void AppendLinkedResource (cmGeneratedFileStream& fout,
static void AppendLinkedResource (cmXMLWriter& xml,
const std::string& name,
const std::string& path,
LinkType linkType);
static void AppendIncludeDirectories(cmGeneratedFileStream& fout,
static void AppendIncludeDirectories(cmXMLWriter& xml,
const std::vector<std::string>& includeDirs,
std::set<std::string>& emittedDirs);
static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar,
static void AddEnvVar(std::ostream& out, const char* envVar,
cmLocalGenerator* lg);
void CreateLinksToSubprojects(cmGeneratedFileStream& fout,
const std::string& baseDir);
void CreateLinksForTargets(cmGeneratedFileStream& fout);
void CreateLinksToSubprojects(cmXMLWriter& xml, const std::string& baseDir);
void CreateLinksForTargets(cmXMLWriter& xml);
std::vector<std::string> SrcLinkedResources;
std::set<std::string> Natures;

View File

@ -18,6 +18,7 @@
#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Directory.hxx>
@ -397,6 +398,7 @@ void cmGlobalKdevelopGenerator
{
return;
}
cmXMLWriter xml(fout);
// check for a version control system
bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
@ -411,182 +413,230 @@ void cmGlobalKdevelopGenerator
primaryLanguage="Fortran77";
}
fout<<"<?xml version = '1.0'?>\n"
"<kdevelop>\n"
" <general>\n"
" <author></author>\n"
" <email></email>\n"
" <version>$VERSION$</version>\n"
" <projectmanagement>KDevCustomProject</projectmanagement>\n"
" <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
" <ignoreparts/>\n"
" <projectdirectory>" << projectDir <<
"</projectdirectory>\n"; //this one is important
fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
xml.StartDocument();
xml.StartElement("kdevelop");
xml.StartElement("general");
xml.Element("author", "");
xml.Element("email", "");
xml.Element("version", "$VERSION$");
xml.Element("projectmanagement", "KDevCustomProject");
xml.Element("primarylanguage", primaryLanguage);
xml.Element("ignoreparts");
xml.Element("projectdirectory", projectDir); // this one is important
xml.Element("absoluteprojectpath", "true"); // and this one
// setup additional languages
fout<<" <secondaryLanguages>\n";
xml.StartElement("secondaryLanguages");
if (enableFortran && enableCxx)
{
fout<<" <language>Fortran</language>\n";
xml.Element("language", "Fortran");
}
if (enableCxx)
{
fout<<" <language>C</language>\n";
xml.Element("language", "C");
}
fout<<" </secondaryLanguages>\n";
xml.EndElement();
if (hasSvn)
{
fout << " <versioncontrol>kdevsubversion</versioncontrol>\n";
xml.Element("versioncontrol", "kdevsubversion");
}
else if (hasCvs)
{
fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
xml.Element("versioncontrol", "kdevcvsservice");
}
fout<<" </general>\n"
" <kdevcustomproject>\n"
" <filelistdirectory>" << outputDir <<
"</filelistdirectory>\n"
" <run>\n"
" <mainprogram>" << executable << "</mainprogram>\n"
" <directoryradio>custom</directoryradio>\n"
" <customdirectory>"<<outputDir<<"</customdirectory>\n"
" <programargs></programargs>\n"
" <terminal>false</terminal>\n"
" <autocompile>true</autocompile>\n"
" <envvars/>\n"
" </run>\n"
" <build>\n"
" <buildtool>make</buildtool>\n"; //this one is important
fout<<" <builddir>"<<outputDir<<"</builddir>\n"; //and this one
fout<<" </build>\n"
" <make>\n"
" <abortonerror>false</abortonerror>\n"
" <numberofjobs>1</numberofjobs>\n"
" <dontact>false</dontact>\n"
" <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")
<< " </makebin>\n"
" <selectedenvironment>default</selectedenvironment>\n"
" <environments>\n"
" <default>\n"
" <envvar value=\"1\" name=\"VERBOSE\" />\n"
" <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n"
" </default>\n"
" </environments>\n"
" </make>\n";
xml.EndElement(); // general
xml.StartElement("kdevcustomproject");
fout<<" <blacklist>\n";
xml.Element("filelistdirectory", outputDir);
xml.StartElement("run");
xml.Element("mainprogram", executable);
xml.Element("directoryradio", "custom");
xml.Element("customdirectory", outputDir);
xml.Element("programargs", "");
xml.Element("terminal", "false");
xml.Element("autocompile", "true");
xml.Element("envvars");
xml.EndElement();
xml.StartElement("build");
xml.Element("buildtool", "make"); // this one is important
xml.Element("builddir", outputDir); // and this one
xml.EndElement();
xml.StartElement("make");
xml.Element("abortonerror", "false");
xml.Element("numberofjobs", 1);
xml.Element("dontact", "false");
xml.Element("makebin", this->GlobalGenerator->GetLocalGenerators()[0]->
GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"));
xml.Element("selectedenvironment", "default");
xml.StartElement("environments");
xml.StartElement("default");
xml.StartElement("envvar");
xml.Attribute("value", 1);
xml.Attribute("name", "VERBOSE");
xml.EndElement();
xml.StartElement("envvar");
xml.Attribute("value", 1);
xml.Attribute("name", "CMAKE_NO_VERBOSE");
xml.EndElement();
xml.EndElement(); // default
xml.EndElement(); // environments
xml.EndElement(); // make
xml.StartElement("blacklist");
for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
dirIt != this->Blacklist.end();
++dirIt)
{
fout<<" <path>" << *dirIt << "</path>\n";
xml.Element("path", *dirIt);
}
fout<<" </blacklist>\n";
xml.EndElement();
fout<<" </kdevcustomproject>\n"
" <kdevfilecreate>\n"
" <filetypes/>\n"
" <useglobaltypes>\n"
" <type ext=\"ui\" />\n"
" <type ext=\"cpp\" />\n"
" <type ext=\"h\" />\n"
" </useglobaltypes>\n"
" </kdevfilecreate>\n"
" <kdevdoctreeview>\n"
" <projectdoc>\n"
" <userdocDir>html/</userdocDir>\n"
" <apidocDir>html/</apidocDir>\n"
" </projectdoc>\n"
" <ignoreqt_xml/>\n"
" <ignoredoxygen/>\n"
" <ignorekdocs/>\n"
" <ignoretocs/>\n"
" <ignoredevhelp/>\n"
" </kdevdoctreeview>\n";
xml.EndElement(); // kdevcustomproject
xml.StartElement("kdevfilecreate");
xml.Element("filetypes");
xml.StartElement("useglobaltypes");
xml.StartElement("type");
xml.Attribute("ext", "ui");
xml.EndElement();
xml.StartElement("type");
xml.Attribute("ext", "cpp");
xml.EndElement();
xml.StartElement("type");
xml.Attribute("ext", "h");
xml.EndElement();
xml.EndElement(); // useglobaltypes
xml.EndElement(); // kdevfilecreate
xml.StartElement("kdevdoctreeview");
xml.StartElement("projectdoc");
xml.Element("userdocDir", "html/");
xml.Element("apidocDir", "html/");
xml.EndElement(); // projectdoc
xml.Element("ignoreqt_xml");
xml.Element("ignoredoxygen");
xml.Element("ignorekdocs");
xml.Element("ignoretocs");
xml.Element("ignoredevhelp");
xml.EndElement(); // kdevdoctreeview;
if (enableCxx)
{
fout<<" <cppsupportpart>\n"
" <filetemplates>\n"
" <interfacesuffix>.h</interfacesuffix>\n"
" <implementationsuffix>.cpp</implementationsuffix>\n"
" </filetemplates>\n"
" </cppsupportpart>\n"
" <kdevcppsupport>\n"
" <codecompletion>\n"
" <includeGlobalFunctions>true</includeGlobalFunctions>\n"
" <includeTypes>true</includeTypes>\n"
" <includeEnums>true</includeEnums>\n"
" <includeTypedefs>false</includeTypedefs>\n"
" <automaticCodeCompletion>true</automaticCodeCompletion>\n"
" <automaticArgumentsHint>true</automaticArgumentsHint>\n"
" <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
" <codeCompletionDelay>250</codeCompletionDelay>\n"
" <argumentsHintDelay>400</argumentsHintDelay>\n"
" <headerCompletionDelay>250</headerCompletionDelay>\n"
" </codecompletion>\n"
" <references/>\n"
" </kdevcppsupport>\n";
xml.StartElement("cppsupportpart");
xml.StartElement("filetemplates");
xml.Element("interfacesuffix", ".h");
xml.Element("implementationsuffix", ".cpp");
xml.EndElement(); // filetemplates
xml.EndElement(); // cppsupportpart
xml.StartElement("kdevcppsupport");
xml.StartElement("codecompletion");
xml.Element("includeGlobalFunctions", "true");
xml.Element("includeTypes", "true");
xml.Element("includeEnums", "true");
xml.Element("includeTypedefs", "false");
xml.Element("automaticCodeCompletion", "true");
xml.Element("automaticArgumentsHint", "true");
xml.Element("automaticHeaderCompletion", "true");
xml.Element("codeCompletionDelay", 250);
xml.Element("argumentsHintDelay", 400);
xml.Element("headerCompletionDelay", 250);
xml.EndElement(); // codecompletion
xml.Element("references");
xml.EndElement(); // kdevcppsupport;
}
if (enableFortran)
{
fout<<" <kdevfortransupport>\n"
" <ftnchek>\n"
" <division>false</division>\n"
" <extern>false</extern>\n"
" <declare>false</declare>\n"
" <pure>false</pure>\n"
" <argumentsall>false</argumentsall>\n"
" <commonall>false</commonall>\n"
" <truncationall>false</truncationall>\n"
" <usageall>false</usageall>\n"
" <f77all>false</f77all>\n"
" <portabilityall>false</portabilityall>\n"
" <argumentsonly/>\n"
" <commononly/>\n"
" <truncationonly/>\n"
" <usageonly/>\n"
" <f77only/>\n"
" <portabilityonly/>\n"
" </ftnchek>\n"
" </kdevfortransupport>\n";
xml.StartElement("kdevfortransupport");
xml.StartElement("ftnchek");
xml.Element("division", "false");
xml.Element("extern", "false");
xml.Element("declare", "false");
xml.Element("pure", "false");
xml.Element("argumentsall", "false");
xml.Element("commonall", "false");
xml.Element("truncationall", "false");
xml.Element("usageall", "false");
xml.Element("f77all", "false");
xml.Element("portabilityall", "false");
xml.Element("argumentsonly");
xml.Element("commononly");
xml.Element("truncationonly");
xml.Element("usageonly");
xml.Element("f77only");
xml.Element("portabilityonly");
xml.EndElement(); // ftnchek
xml.EndElement(); // kdevfortransupport;
}
// set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
// command
fout<<" <kdevfileview>\n"
" <groups>\n"
" <group pattern=\"" << cmakeFilePattern <<
"\" name=\"CMake\" />\n";
xml.StartElement("kdevfileview");
xml.StartElement("groups");
xml.StartElement("group");
xml.Attribute("pattern", cmakeFilePattern);
xml.Attribute("name", "CMake");
xml.EndElement();
if (enableCxx)
{
fout<<" <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
" <group pattern=\"*.c\" name=\"C Sources\" />\n"
" <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
"/>\n";
xml.StartElement("group");
xml.Attribute("pattern", "*.h;*.hxx;*.hpp");
xml.Attribute("name", "Header");
xml.EndElement();
xml.StartElement("group");
xml.Attribute("pattern", "*.c");
xml.Attribute("name", "C Sources");
xml.EndElement();
xml.StartElement("group");
xml.Attribute("pattern", "*.cpp;*.C;*.cxx;*.cc");
xml.Attribute("name", "C++ Sources");
xml.EndElement();
}
if (enableFortran)
{
fout<<" <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
"*.F95\" name=\"Fortran Sources\" />\n";
xml.StartElement("group");
xml.Attribute("pattern",
"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;*.F95");
xml.Attribute("name", "Fortran Sources");
xml.EndElement();
}
fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
" <hidenonprojectfiles>true</hidenonprojectfiles>\n"
" </groups>\n"
" <tree>\n"
" <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
" <hidenonprojectfiles>true</hidenonprojectfiles>\n"
" </tree>\n"
" </kdevfileview>\n"
"</kdevelop>\n";
xml.StartElement("group");
xml.Attribute("pattern", "*.ui");
xml.Attribute("name", "Qt Designer files");
xml.EndElement();
xml.Element("hidenonprojectfiles", "true");
xml.EndElement(); // groups
xml.StartElement("tree");
xml.Element("hidepatterns", "*.o,*.lo,CVS,*~,cmake*");
xml.Element("hidenonprojectfiles", "true");
xml.EndElement(); // tree
xml.EndElement(); // kdevfileview
xml.EndElement(); // kdevelop;
xml.EndDocument();
if (sessionFilename.empty())
{
@ -600,15 +650,24 @@ void cmGlobalKdevelopGenerator
{
return;
}
devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
"<!DOCTYPE KDevPrjSession>\n"
"<KDevPrjSession>\n"
" <DocsAndViews NumberOfDocuments=\"1\" >\n"
" <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen <<
"\" >\n"
" <View0 line=\"0\" Type=\"Source\" />\n"
" </Doc0>\n"
" </DocsAndViews>\n"
"</KDevPrjSession>\n";
}
cmXMLWriter sesxml(devses);
sesxml.StartDocument("UTF-8");
sesxml.Doctype("KDevPrjSession");
sesxml.StartElement("KDevPrjSession");
sesxml.StartElement("DocsAndViews");
sesxml.Attribute("NumberOfDocuments", 1);
sesxml.StartElement("Doc0");
sesxml.Attribute("NumberOfViews", 1);
sesxml.Attribute("URL", "file://" + fileToOpen);
sesxml.StartElement("View0");
sesxml.Attribute("line", 0);
sesxml.Attribute("Type", "Source");
sesxml.EndElement(); // View0
sesxml.EndElement(); // Doc0
sesxml.EndElement(); // DocsAndViews
sesxml.EndElement(); // KDevPrjSession;
}

View File

@ -67,6 +67,13 @@ void cmXMLWriter::EndElement()
this->ElementOpen = false;
}
void cmXMLWriter::Element(const char* name)
{
this->CloseStartElement();
this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
this->Output << '<' << name << "/>";
}
void cmXMLWriter::BreakAttributes()
{
this->BreakAttrib = true;
@ -85,6 +92,13 @@ void cmXMLWriter::CData(std::string const& data)
this->Output << "<![CDATA[" << data << "]]>";
}
void cmXMLWriter::Doctype(const char* doctype)
{
this->CloseStartElement();
this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
this->Output << "<!DOCTYPE " << doctype << ">";
}
void cmXMLWriter::ProcessingInstruction(const char* target, const char* data)
{
this->CloseStartElement();

View File

@ -41,6 +41,8 @@ public:
this->Output << name << "=\"" << SafeAttribute(value) << '"';
}
void Element(const char* name);
template <typename T>
void Element(std::string const& name, T const& value)
{
@ -60,6 +62,8 @@ public:
void CData(std::string const& data);
void Doctype(const char* doctype);
void ProcessingInstruction(const char* target, const char* data);
void FragmentFile(const char* fname);