diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 018ab24f0..b4f767084 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -18,6 +18,7 @@ #include "cmSourceFile.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" +#include "cmXMLWriter.h" #include #include @@ -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<<"\n" - "\n" - " \n" - " \n" - " \n" - " $VERSION$\n" - " KDevCustomProject\n" - " " << primaryLanguage << "\n" - " \n" - " " << projectDir << - "\n"; //this one is important - fout<<" true\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<<" \n"; + xml.StartElement("secondaryLanguages"); if (enableFortran && enableCxx) { - fout<<" Fortran\n"; + xml.Element("language", "Fortran"); } if (enableCxx) { - fout<<" C\n"; + xml.Element("language", "C"); } - fout<<" \n"; + xml.EndElement(); if (hasSvn) { - fout << " kdevsubversion\n"; + xml.Element("versioncontrol", "kdevsubversion"); } else if (hasCvs) { - fout << " kdevcvsservice\n"; + xml.Element("versioncontrol", "kdevcvsservice"); } - fout<<" \n" - " \n" - " " << outputDir << - "\n" - " \n" - " " << executable << "\n" - " custom\n" - " "<\n" - " \n" - " false\n" - " true\n" - " \n" - " \n" - " \n" - " make\n"; //this one is important - fout<<" "<\n"; //and this one - fout<<" \n" - " \n" - " false\n" - " 1\n" - " false\n" - " " << this->GlobalGenerator->GetLocalGenerators()[0]-> - GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM") - << " \n" - " default\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n"; + xml.EndElement(); // general + xml.StartElement("kdevcustomproject"); - fout<<" \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::const_iterator dirIt=this->Blacklist.begin(); dirIt != this->Blacklist.end(); ++dirIt) { - fout<<" " << *dirIt << "\n"; + xml.Element("path", *dirIt); } - fout<<" \n"; + xml.EndElement(); - fout<<" \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " html/\n" - " html/\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \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<<" \n" - " \n" - " .h\n" - " .cpp\n" - " \n" - " \n" - " \n" - " \n" - " true\n" - " true\n" - " true\n" - " false\n" - " true\n" - " true\n" - " true\n" - " 250\n" - " 400\n" - " 250\n" - " \n" - " \n" - " \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<<" \n" - " \n" - " false\n" - " false\n" - " false\n" - " false\n" - " false\n" - " false\n" - " false\n" - " false\n" - " false\n" - " false\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \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<<" \n" - " \n" - " \n"; + xml.StartElement("kdevfileview"); + xml.StartElement("groups"); + + xml.StartElement("group"); + xml.Attribute("pattern", cmakeFilePattern); + xml.Attribute("name", "CMake"); + xml.EndElement(); if (enableCxx) { - fout<<" \n" - " \n" - " \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<<" \n"; + xml.StartElement("group"); + xml.Attribute("pattern", + "*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;*.F95"); + xml.Attribute("name", "Fortran Sources"); + xml.EndElement(); } - fout<<" \n" - " true\n" - " \n" - " \n" - " *.o,*.lo,CVS,*~,cmake*\n" - " true\n" - " \n" - " \n" - "\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<<"\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\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; +}