summaryrefslogtreecommitdiffstats
path: root/Source/cmExtraSublimeTextGenerator.cxx
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2013-02-06 18:31:44 (GMT)
committerBrad King <brad.king@kitware.com>2013-02-19 19:43:20 (GMT)
commit4760eade425e8e294ac9400785ffce70912d5b43 (patch)
tree42c6a522be0010a7cfc22bbe453bff89dee570b1 /Source/cmExtraSublimeTextGenerator.cxx
parentda0898e0a2f01cfbc5f2a1061ea94662fd3e455e (diff)
downloadCMake-4760eade425e8e294ac9400785ffce70912d5b43.zip
CMake-4760eade425e8e294ac9400785ffce70912d5b43.tar.gz
CMake-4760eade425e8e294ac9400785ffce70912d5b43.tar.bz2
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.
Diffstat (limited to 'Source/cmExtraSublimeTextGenerator.cxx')
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx102
1 files changed, 4 insertions, 98 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index d10179e..ef29329 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -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,108 +140,14 @@ 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);
-}
-
-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";
+ fout << "\n\t}";
}
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,
const cmMakefile* mf,
cmGeneratedFileStream& fout,