diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2020-03-24 04:19:36 (GMT) |
---|---|---|
committer | Alex Turbov <i.zaufi@gmail.com> | 2020-03-24 13:33:33 (GMT) |
commit | 8e3a65d96340f523e6ca8ac86b9360a94fe08fb9 (patch) | |
tree | 6d2af5dfd3b3512cf35d441751e6e396ef10f551 /Source/cmGlobalGhsMultiGenerator.cxx | |
parent | 7099db5dd48d36e5d39ab17219278d834c8a88a7 (diff) | |
download | CMake-8e3a65d96340f523e6ca8ac86b9360a94fe08fb9.zip CMake-8e3a65d96340f523e6ca8ac86b9360a94fe08fb9.tar.gz CMake-8e3a65d96340f523e6ca8ac86b9360a94fe08fb9.tar.bz2 |
Refactor: Avoid `std::endl` where it's not necessary (part 3)
The `std::endl` manipulator, except inserting `\n` character, also
performs `os.flush()`, which may lead to undesired effects (like
disk I/O in the middle of forming data strings). For the
`std::stringstream` it also has no meaning.
* replace multiple `operator<<` calls on a string literal w/
the only call and the only (bigger) string literal;
* replace one character string literal used in `operator<<`
w/ a char literal.
Diffstat (limited to 'Source/cmGlobalGhsMultiGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGhsMultiGenerator.cxx | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 9754fd5..289a035 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -254,14 +254,15 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, void cmGlobalGhsMultiGenerator::WriteFileHeader(std::ostream& fout) { - fout << "#!gbuild" << std::endl; - fout << "#" << std::endl - << "# CMAKE generated file: DO NOT EDIT!" << std::endl - << "# Generated by \"" << GetActualName() << "\"" - << " Generator, CMake Version " << cmVersion::GetMajorVersion() << "." - << cmVersion::GetMinorVersion() << std::endl - << "#" << std::endl - << std::endl; + /* clang-format off */ + fout << "#!gbuild\n" + "#\n" + "# CMAKE generated file: DO NOT EDIT!\n" + "# Generated by \"" << GetActualName() << "\"" + " Generator, CMake Version " << cmVersion::GetMajorVersion() << '.' + << cmVersion::GetMinorVersion() << "\n" + "#\n\n"; + /* clang-format on */ } void cmGlobalGhsMultiGenerator::WriteCustomRuleBOD(std::ostream& fout) @@ -269,36 +270,36 @@ void cmGlobalGhsMultiGenerator::WriteCustomRuleBOD(std::ostream& fout) fout << "Commands {\n" " Custom_Rule_Command {\n" " name = \"Custom Rule Command\"\n" - " exec = \""; + " exec = \"" #ifdef _WIN32 - fout << "cmd.exe"; + "cmd.exe" #else - fout << "/bin/sh"; + "/bin/sh" #endif - fout << "\"\n" + "\"\n" " options = {\"SpecialOptions\"}\n" " }\n" - "}\n"; + "}\n" - fout << "\n\n"; - fout << "FileTypes {\n" + "\n\n" + "FileTypes {\n" " CmakeRule {\n" " name = \"Custom Rule\"\n" " action = \"&Run\"\n" - " extensions = {\""; + " extensions = {\"" #ifdef _WIN32 - fout << "bat"; + "bat" #else - fout << "sh"; + "sh" #endif - fout << "\"}\n" + "\"}\n" " grepable = false\n" " command = \"Custom Rule Command\"\n" - " commandLine = \"$COMMAND "; + " commandLine = \"$COMMAND " #ifdef _WIN32 - fout << "/c"; + "/c" #endif - fout << " $INPUTFILE\"\n" + " $INPUTFILE\"\n" " progress = \"Processing Custom Rule\"\n" " promoteToFirstPass = true\n" " outputType = \"None\"\n" @@ -328,13 +329,13 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout, this->WriteHighLevelDirectives(root, fout); GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fout); - fout << "# Top Level Project File" << std::endl; + fout << "# Top Level Project File\n"; // Specify BSP option if supplied by user const char* bspName = this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME"); if (!cmIsOff(bspName)) { - fout << " -bsp " << bspName << std::endl; + fout << " -bsp " << bspName << '\n'; } // Specify OS DIR if supplied by user @@ -349,14 +350,14 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout, } else { fout << osDirOption; } - fout << "\"" << this->OsDir << "\"" << std::endl; + fout << "\"" << this->OsDir << "\"\n"; } } void cmGlobalGhsMultiGenerator::WriteSubProjects(std::ostream& fout, std::string& all_target) { - fout << "CMakeFiles/" << all_target << " [Project]" << std::endl; + fout << "CMakeFiles/" << all_target << " [Project]\n"; // All known targets for (cmGeneratorTarget const* target : this->ProjectTargets) { if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY || @@ -367,7 +368,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(std::ostream& fout, continue; } fout << "CMakeFiles/" << target->GetName() + ".tgt" + FILE_EXTENSION - << " [Project]" << std::endl; + << " [Project]\n"; } } @@ -391,7 +392,7 @@ void cmGlobalGhsMultiGenerator::WriteProjectLine( std::string projFile = dir + projName + FILE_EXTENSION; fout << projFile; - fout << " " << projType << std::endl; + fout << ' ' << projType << '\n'; } else { /* Should never happen */ std::string message = @@ -613,14 +614,14 @@ cmGlobalGhsMultiGenerator::GenerateBuildCommand( void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout, cmLocalGenerator* root) { - fout << "macro PROJ_NAME=" << root->GetProjectName() << std::endl; + fout << "macro PROJ_NAME=" << root->GetProjectName() << '\n'; char const* ghsGpjMacros = this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS"); if (nullptr != ghsGpjMacros) { std::vector<std::string> expandedList = cmExpandedList(std::string(ghsGpjMacros)); for (std::string const& arg : expandedList) { - fout << "macro " << arg << std::endl; + fout << "macro " << arg << '\n'; } } } @@ -643,17 +644,19 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives( tgt = cmStrCat((a ? a : ""), '_', (p ? p : ""), ".tgt"); } - fout << "primaryTarget=" << tgt << std::endl; - fout << "customization=" << root->GetBinaryDirectory() - << "/CMakeFiles/custom_rule.bod" << std::endl; - fout << "customization=" << root->GetBinaryDirectory() - << "/CMakeFiles/custom_target.bod" << std::endl; + /* clang-format off */ + fout << "primaryTarget=" << tgt << "\n" + "customization=" << root->GetBinaryDirectory() + << "/CMakeFiles/custom_rule.bod\n" + "customization=" << root->GetBinaryDirectory() + << "/CMakeFiles/custom_target.bod" << '\n'; + /* clang-format on */ char const* const customization = this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION"); if (nullptr != customization && strlen(customization) > 0) { fout << "customization=" - << cmGlobalGhsMultiGenerator::TrimQuotes(customization) << std::endl; + << cmGlobalGhsMultiGenerator::TrimQuotes(customization) << '\n'; this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION"); } } |