Remove ability to generate sublime clang files.

SublimeClang is a optional plugin to SublimeText and I felt it
shouldn't be part of the generator for the following reasons:

1. Reduces the amount of sublime and sublimeClang specific
   code we have to maintain inside CMake.
2. In testing the SublimeClang commands generated did not work
   for the VTK project.

For people that do want this feature I recommend that they
looking into https://gist.github.com/robertmaynard/4724705 for a
way to use CMAKE_EXPORT_COMPILE_COMMANDS to generate JSON files
that can be used by SublimeClang.
This commit is contained in:
Robert Maynard 2013-02-06 13:31:44 -05:00 committed by Brad King
parent da0898e0a2
commit 4760eade42
3 changed files with 5 additions and 109 deletions

View File

@ -904,14 +904,6 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"only be used when evaluating the INCLUDE_DIRECTORIES target property. "
"In that case, it outputs a backtrace for each include directory in "
"the build. Default is unset.",false,"Variables That Change Behavior");
cm->DefineProperty
("CMAKE_SUBLIMECLANG_DISABLED", cmProperty::VARIABLE,
"Used by the Sublime Text 2 generator to disable SublimeClang in "
"generated project files.",
"For very large projects SublimeClang might run slowly. Set this variable"
" to TRUE to instruct the Sublime Text 2 generator to disable "
" SublimeClang in the generated project files.", false,
"Variables That Change Behavior");
// Variables defined by CMake that describe the system

View File

@ -87,8 +87,8 @@ void cmExtraSublimeTextGenerator::CreateProjectFile(
std::string outputDir=mf->GetStartOutputDirectory();
std::string projectName=mf->GetProjectName();
std::string filename=outputDir+"/";
filename+=projectName+".sublime-project";
const std::string filename =
outputDir + "/" + projectName + ".sublime-project";
this->CreateNewProjectFile(lgs, filename);
}
@ -140,106 +140,12 @@ void cmExtraSublimeTextGenerator
// wide
MapSourceFileFlags sourceFileFlags;
AppendAllTargets(lgs, mf, fout, sourceFileFlags);
// End of build_systems
fout << "\n\t]";
// Write the settings section with sublimeclang options
fout << ",\n\t\"settings\":\n\t{\n\t";
// Check if the CMAKE_SUBLIMECLANG_DISABLED flag has been set. If it has
// disable sublimeclang for this project.
const char* sublimeclangDisabledValue =
mf->GetSafeDefinition("CMAKE_SUBLIMECLANG_DISABLED");
bool sublimeclangEnabled = cmSystemTools::IsOff(sublimeclangDisabledValue);
// Per project sublimeclang settings override default and user settings,
// so we only write the sublimeclang_enabled setting to the project file
// if it is set to be disabled.
if (!sublimeclangEnabled)
{
fout << "\t\"sublimeclang_enabled\": false,\n\t";
}
std::string outputDir = mf->GetStartOutputDirectory();
std::string projectName = mf->GetProjectName();
std::string sublimeClangOptionsFilename = outputDir+"/";
sublimeClangOptionsFilename += projectName + ".sublimeclang-options";
std::string sublimeClangOptionsScriptFilename = outputDir + "/"
+ projectName + "_sublimeclang_options_script.py";
fout << "\t\"sublimeclang_options_script\": \"python "
<< sublimeClangOptionsScriptFilename << " "
<< sublimeClangOptionsFilename
<< "\"\n\t";
// End of the settings section
fout << "}\n";
// End of file
fout << "}";
this->WriteSublimeClangOptionsFile(sourceFileFlags,
sublimeClangOptionsFilename);
this->WriteSublimeClangOptionsScript(sublimeClangOptionsScriptFilename);
fout << "\n\t}";
}
void cmExtraSublimeTextGenerator::
WriteSublimeClangOptionsScript(const std::string& filename)
{
cmGeneratedFileStream fout(filename.c_str());
if(!fout)
{
return;
}
fout << "import json\n";
fout << "import sys\n\n\n";
fout << "if len(sys.argv) < 2:\n";
fout << " sys.exit(1)\n";
fout << "data = None\n";
fout << "with open(sys.argv[1]) as f:\n";
fout << " data = json.load(f)\n";
fout << "if data is not None:\n";
fout << " for arg in data.get(sys.argv[2], []):\n";
fout << " print arg\n";
}
void cmExtraSublimeTextGenerator::
WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
const std::string& filename)
{
cmGeneratedFileStream fout(filename.c_str());
if(!fout)
{
return;
}
fout << "{\n";
MapSourceFileFlags::const_iterator sourceFileFlagsEnd =
sourceFileFlags.end();
int totalFiles = sourceFileFlags.size();
int fileIndex = 0;
for (MapSourceFileFlags::const_iterator iter = sourceFileFlags.begin();
iter != sourceFileFlagsEnd; ++iter)
{
const std::string& sourceFilePath = iter->first;
const std::vector<std::string>& flags = iter->second;
fout << "\t\"" << sourceFilePath << "\":\n\t[\n\t";
std::vector<std::string>::const_iterator flagsEnd = flags.end();
for (std::vector<std::string>::const_iterator flagsIter = flags.begin();
flagsIter != flagsEnd; ++flagsIter)
{
fout << "\t\"" << *flagsIter << "\"";
if (flagsIter + 1 != flagsEnd)
{
fout << ",";
}
fout << "\n\t";
}
fout << "]";
if (fileIndex < totalFiles - 1)
{
fout << ",";
}
fout << "\n";
fileIndex++;
}
fout << "}\n";
}
void cmExtraSublimeTextGenerator::
AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,

View File

@ -48,9 +48,7 @@ private:
void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
const std::string& filename);
void WriteSublimeClangOptionsScript(const std::string& filename);
void WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
const std::string& filename);
/** Appends all targets as build systems to the project file and get all
* include directories and compiler definitions used.
*/