diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/cmExtraKateGenerator.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2 |
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Diffstat (limited to 'Source/cmExtraKateGenerator.cxx')
-rw-r--r-- | Source/cmExtraKateGenerator.cxx | 273 |
1 files changed, 118 insertions, 155 deletions
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index f221604..02159dd 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -22,15 +22,15 @@ #include <cmsys/SystemTools.hxx> -void cmExtraKateGenerator -::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const +void cmExtraKateGenerator::GetDocumentation(cmDocumentationEntry& entry, + const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates Kate project files."; } cmExtraKateGenerator::cmExtraKateGenerator() -:cmExternalMakefileProjectGenerator() + : cmExternalMakefileProjectGenerator() { #if defined(_WIN32) this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); @@ -42,31 +42,28 @@ cmExtraKateGenerator::cmExtraKateGenerator() this->SupportedGlobalGenerators.push_back("Unix Makefiles"); } - void cmExtraKateGenerator::Generate() { cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; const cmMakefile* mf = lg->GetMakefile(); - this->ProjectName = this->GenerateProjectName(lg->GetProjectName(), - mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), - this->GetPathBasename(lg->GetBinaryDirectory())); + this->ProjectName = this->GenerateProjectName( + lg->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), + this->GetPathBasename(lg->GetBinaryDirectory())); this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja"); this->CreateKateProjectFile(lg); this->CreateDummyKateProjectFile(lg); } - void cmExtraKateGenerator::CreateKateProjectFile( - const cmLocalGenerator* lg) const + const cmLocalGenerator* lg) const { std::string filename = lg->GetBinaryDirectory(); filename += "/.kateproject"; cmGeneratedFileStream fout(filename.c_str()); - if (!fout) - { + if (!fout) { return; - } + } /* clang-format off */ fout << @@ -79,15 +76,13 @@ void cmExtraKateGenerator::CreateKateProjectFile( fout << "}\n"; } - -void -cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, - cmGeneratedFileStream& fout) const +void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, + cmGeneratedFileStream& fout) const { cmMakefile const* mf = lg->GetMakefile(); const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - const std::string makeArgs = mf->GetSafeDefinition( - "CMAKE_KATE_MAKE_ARGUMENTS"); + const std::string makeArgs = + mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); const char* homeOutputDir = lg->GetBinaryDirectory(); /* clang-format off */ @@ -99,178 +94,154 @@ cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, /* clang-format on */ // build, clean and quick are for the build plugin kate <= 4.12: - fout << "\t\t\"build\": \"" << make << " -C \\\"" << homeOutputDir - << "\\\" " << makeArgs << " " << "all\",\n"; - fout << "\t\t\"clean\": \"" << make << " -C \\\"" << homeOutputDir - << "\\\" " << makeArgs << " " << "clean\",\n"; - fout << "\t\t\"quick\": \"" << make << " -C \\\"" << homeOutputDir - << "\\\" " << makeArgs << " " << "install\",\n"; + fout << "\t\t\"build\": \"" << make << " -C \\\"" << homeOutputDir << "\\\" " + << makeArgs << " " + << "all\",\n"; + fout << "\t\t\"clean\": \"" << make << " -C \\\"" << homeOutputDir << "\\\" " + << makeArgs << " " + << "clean\",\n"; + fout << "\t\t\"quick\": \"" << make << " -C \\\"" << homeOutputDir << "\\\" " + << makeArgs << " " + << "install\",\n"; // this is for kate >= 4.13: - fout << - "\t\t\"targets\":[\n"; + fout << "\t\t\"targets\":[\n"; - this->AppendTarget(fout, "all", make, makeArgs, - homeOutputDir, homeOutputDir); - this->AppendTarget(fout, "clean", make, makeArgs, - homeOutputDir, homeOutputDir); + this->AppendTarget(fout, "all", make, makeArgs, homeOutputDir, + homeOutputDir); + this->AppendTarget(fout, "clean", make, makeArgs, homeOutputDir, + homeOutputDir); // add all executable and library targets and some of the GLOBAL // and UTILITY targets - for (std::vector<cmLocalGenerator*>::const_iterator - it = this->GlobalGenerator->GetLocalGenerators().begin(); - it != this->GlobalGenerator->GetLocalGenerators().end(); - ++it) - { + for (std::vector<cmLocalGenerator*>::const_iterator it = + this->GlobalGenerator->GetLocalGenerators().begin(); + it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { const std::vector<cmGeneratorTarget*> targets = - (*it)->GetGeneratorTargets(); + (*it)->GetGeneratorTargets(); std::string currentDir = (*it)->GetCurrentBinaryDirectory(); bool topLevel = (currentDir == (*it)->GetBinaryDirectory()); - for(std::vector<cmGeneratorTarget*>::const_iterator ti = - targets.begin(); ti!=targets.end(); ++ti) - { + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); + ti != targets.end(); ++ti) { std::string targetName = (*ti)->GetName(); - switch((*ti)->GetType()) - { - case cmState::GLOBAL_TARGET: - { + switch ((*ti)->GetType()) { + case cmState::GLOBAL_TARGET: { bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs - if (topLevel) - { + if (topLevel) { insertTarget = true; // only add the "edit_cache" target if it's not ccmake, because // this will not work within the IDE - if (targetName == "edit_cache") - { - const char* editCommand = (*it)->GetMakefile()->GetDefinition - ("CMAKE_EDIT_COMMAND"); - if (editCommand == 0) - { + if (targetName == "edit_cache") { + const char* editCommand = + (*it)->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND"); + if (editCommand == 0) { insertTarget = false; - } - else if (strstr(editCommand, "ccmake")!=NULL) - { + } else if (strstr(editCommand, "ccmake") != NULL) { insertTarget = false; - } } } - if (insertTarget) - { - this->AppendTarget(fout, targetName, make, makeArgs, - currentDir, homeOutputDir); - } - } - break; + } + if (insertTarget) { + this->AppendTarget(fout, targetName, make, makeArgs, currentDir, + homeOutputDir); + } + } break; case cmState::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart - if (((targetName.find("Nightly")==0) &&(targetName!="Nightly")) - || ((targetName.find("Continuous")==0) - &&(targetName!="Continuous")) - || ((targetName.find("Experimental")==0) - && (targetName!="Experimental"))) - { - break; - } - - this->AppendTarget(fout, targetName, make, makeArgs, - currentDir, homeOutputDir); + if (((targetName.find("Nightly") == 0) && + (targetName != "Nightly")) || + ((targetName.find("Continuous") == 0) && + (targetName != "Continuous")) || + ((targetName.find("Experimental") == 0) && + (targetName != "Experimental"))) { + break; + } + + this->AppendTarget(fout, targetName, make, makeArgs, currentDir, + homeOutputDir); break; case cmState::EXECUTABLE: case cmState::STATIC_LIBRARY: case cmState::SHARED_LIBRARY: case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: - { - this->AppendTarget(fout, targetName, make, makeArgs, - currentDir, homeOutputDir); + case cmState::OBJECT_LIBRARY: { + this->AppendTarget(fout, targetName, make, makeArgs, currentDir, + homeOutputDir); std::string fastTarget = targetName; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget, make, makeArgs, - currentDir, homeOutputDir); + this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir, + homeOutputDir); - } - break; + } break; default: break; } } - //insert rules for compiling, preprocessing and assembling individual files + // insert rules for compiling, preprocessing and assembling individual + // files std::vector<std::string> objectFileTargets; (*it)->GetIndividualFileTargets(objectFileTargets); - for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin(); - fit != objectFileTargets.end(); - ++fit) - { - this->AppendTarget(fout, *fit, make, makeArgs, currentDir,homeOutputDir); - } + for (std::vector<std::string>::const_iterator fit = + objectFileTargets.begin(); + fit != objectFileTargets.end(); ++fit) { + this->AppendTarget(fout, *fit, make, makeArgs, currentDir, + homeOutputDir); + } } - fout << - "\t] }\n"; + fout << "\t] }\n"; } - -void -cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, - const std::string& target, - const std::string& make, - const std::string& makeArgs, - const std::string& path, - const char* homeOutputDir - ) const +void cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, + const std::string& target, + const std::string& make, + const std::string& makeArgs, + const std::string& path, + const char* homeOutputDir) const { static char JsonSep = ' '; - fout << - "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", " - "\"build_cmd\":\"" << make - << " -C \\\"" << (this->UseNinja ? homeOutputDir : path.c_str()) - << "\\\" " << makeArgs << " " - << target << "\"}\n"; + fout << "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", " + "\"build_cmd\":\"" + << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path.c_str()) + << "\\\" " << makeArgs << " " << target << "\"}\n"; JsonSep = ','; } - - -void -cmExtraKateGenerator::CreateDummyKateProjectFile( - const cmLocalGenerator* lg) const +void cmExtraKateGenerator::CreateDummyKateProjectFile( + const cmLocalGenerator* lg) const { std::string filename = lg->GetBinaryDirectory(); filename += "/"; filename += this->ProjectName; filename += ".kateproject"; cmGeneratedFileStream fout(filename.c_str()); - if (!fout) - { + if (!fout) { return; - } + } fout << "#Generated by " << cmSystemTools::GetCMakeCommand() << ", do not edit.\n"; } - -std::string -cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const +std::string cmExtraKateGenerator::GenerateFilesString( + const cmLocalGenerator* lg) const { std::string s = lg->GetSourceDirectory(); s += "/.git"; - if(cmSystemTools::FileExists(s.c_str())) - { + if (cmSystemTools::FileExists(s.c_str())) { return std::string("\"git\": 1 "); } s = lg->GetSourceDirectory(); s += "/.svn"; - if(cmSystemTools::FileExists(s.c_str())) - { + if (cmSystemTools::FileExists(s.c_str())) { return std::string("\"svn\": 1 "); } @@ -279,77 +250,69 @@ cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const std::set<std::string> files; std::string tmp; - const std::vector<cmLocalGenerator *>& lgs = - this->GlobalGenerator->GetLocalGenerators(); - - for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin(); - it!=lgs.end(); it++) - { - cmMakefile* makefile=(*it)->GetMakefile(); - const std::vector<std::string>& listFiles=makefile->GetListFiles(); - for (std::vector<std::string>::const_iterator lt=listFiles.begin(); - lt!=listFiles.end(); lt++) + const std::vector<cmLocalGenerator*>& lgs = + this->GlobalGenerator->GetLocalGenerators(); + + for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin(); + it != lgs.end(); it++) { + cmMakefile* makefile = (*it)->GetMakefile(); + const std::vector<std::string>& listFiles = makefile->GetListFiles(); + for (std::vector<std::string>::const_iterator lt = listFiles.begin(); + lt != listFiles.end(); lt++) { + tmp = *lt; { - tmp=*lt; - { files.insert(tmp); - } } + } const std::vector<cmSourceFile*>& sources = makefile->GetSourceFiles(); for (std::vector<cmSourceFile*>::const_iterator sfIt = sources.begin(); - sfIt != sources.end(); sfIt++) - { + sfIt != sources.end(); sfIt++) { cmSourceFile* sf = *sfIt; - if (sf->GetPropertyAsBool("GENERATED")) - { + if (sf->GetPropertyAsBool("GENERATED")) { continue; - } + } tmp = sf->GetFullPath(); files.insert(tmp); - } } + } const char* sep = ""; tmp = "\"list\": ["; - for(std::set<std::string>::const_iterator it = files.begin(); - it != files.end(); ++it) - { + for (std::set<std::string>::const_iterator it = files.begin(); + it != files.end(); ++it) { tmp += sep; tmp += " \""; tmp += *it; tmp += "\""; sep = ","; - } + } tmp += "] "; return tmp; } - -std::string cmExtraKateGenerator::GenerateProjectName(const std::string& name, - const std::string& type, - const std::string& path) const +std::string cmExtraKateGenerator::GenerateProjectName( + const std::string& name, const std::string& type, + const std::string& path) const { return name + (type.empty() ? "" : "-") + type + "@" + path; } - -std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const +std::string cmExtraKateGenerator::GetPathBasename( + const std::string& path) const { std::string outputBasename = path; while (!outputBasename.empty() && (outputBasename[outputBasename.size() - 1] == '/' || - outputBasename[outputBasename.size() - 1] == '\\')) - { + outputBasename[outputBasename.size() - 1] == '\\')) { outputBasename.resize(outputBasename.size() - 1); - } + } std::string::size_type loc = outputBasename.find_last_of("/\\"); - if (loc != std::string::npos) - { + if (loc != std::string::npos) { outputBasename = outputBasename.substr(loc + 1); - } + } return outputBasename; } |