summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGhsMultiGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGlobalGhsMultiGenerator.cxx')
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx99
1 files changed, 49 insertions, 50 deletions
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index bb9dd37..289a035 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -9,6 +9,7 @@
#include <utility>
#include <cm/memory>
+#include <cm/string>
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
@@ -90,7 +91,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
/* store the full toolset for later use
* -- already done if -T<toolset> was specified
*/
- mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsp.c_str(),
+ mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsp,
"Location of generator toolset.",
cmStateEnums::INTERNAL);
}
@@ -112,8 +113,8 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
}
/* store the toolset that is being used for this build */
- mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(),
- "build program to use", cmStateEnums::INTERNAL, true);
+ mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild, "build program to use",
+ cmStateEnums::INTERNAL, true);
mf->AddDefinition("CMAKE_SYSTEM_VERSION", tsp);
@@ -132,7 +133,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
/* store the platform name for later use
* -- already done if -A<arch> was specified
*/
- mf->AddCacheDefinition("CMAKE_GENERATOR_PLATFORM", arch.c_str(),
+ mf->AddCacheDefinition("CMAKE_GENERATOR_PLATFORM", arch,
"Name of generator platform.",
cmStateEnums::INTERNAL);
} else {
@@ -166,7 +167,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
if (cmIsOff(bspName) && platform.find("integrity") != std::string::npos) {
bspName = "sim" + arch;
/* write back the calculate name for next time */
- mf->AddCacheDefinition("GHS_BSP_NAME", bspName.c_str(),
+ mf->AddCacheDefinition("GHS_BSP_NAME", bspName,
"Name of GHS target platform.",
cmStateEnums::STRING, true);
std::string m = cmStrCat(
@@ -253,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)
@@ -268,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"
@@ -327,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
@@ -348,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 ||
@@ -366,7 +368,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(std::ostream& fout,
continue;
}
fout << "CMakeFiles/" << target->GetName() + ".tgt" + FILE_EXTENSION
- << " [Project]" << std::endl;
+ << " [Project]\n";
}
}
@@ -390,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 =
@@ -612,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';
}
}
}
@@ -642,30 +644,27 @@ 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=" << this->TrimQuotes(customization) << std::endl;
+ fout << "customization="
+ << cmGlobalGhsMultiGenerator::TrimQuotes(customization) << '\n';
this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION");
}
}
-std::string cmGlobalGhsMultiGenerator::TrimQuotes(std::string const& str)
+std::string cmGlobalGhsMultiGenerator::TrimQuotes(std::string str)
{
- std::string result;
- result.reserve(str.size());
- for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
- if (*ch != '"') {
- result += *ch;
- }
- }
- return result;
+ cm::erase(str, '"');
+ return str;
}
bool cmGlobalGhsMultiGenerator::TargetCompare::operator()(