cmGlobalKdevelopGenerator: port to cmXMLWriter

This commit is contained in:
Daniel Pfeifer 2015-07-16 23:07:15 +02:00 committed by Brad King
parent dcdc270eeb
commit c45671b0f1
1 changed files with 203 additions and 144 deletions

View File

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