MCPcopy Create free account
hub / github.com/Kitware/CMake / AppendEcho

Method AppendEcho

Source/cmLocalUnixMakefileGenerator3.cxx:1232–1305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1230}
1231
1232void cmLocalUnixMakefileGenerator3::AppendEcho(
1233 std::vector<std::string>& commands, std::string const& text, EchoColor color,
1234 EchoProgress const* progress)
1235{
1236 // Choose the color for the text.
1237 std::string color_name;
1238 if (this->GlobalGenerator->GetToolSupportsColor() && this->ColorMakefile) {
1239 // See cmake::ExecuteEchoColor in cmake.cxx for these options.
1240 // This color set is readable on both black and white backgrounds.
1241 switch (color) {
1242 case EchoNormal:
1243 break;
1244 case EchoDepend:
1245 color_name = "--magenta --bold ";
1246 break;
1247 case EchoBuild:
1248 color_name = "--green ";
1249 break;
1250 case EchoLink:
1251 color_name = "--green --bold ";
1252 break;
1253 case EchoGenerate:
1254 color_name = "--blue --bold ";
1255 break;
1256 case EchoGlobal:
1257 color_name = "--cyan ";
1258 break;
1259 }
1260 }
1261
1262 // Echo one line at a time.
1263 std::string line;
1264 line.reserve(200);
1265 for (char const* c = text.c_str();; ++c) {
1266 if (*c == '\n' || *c == '\0') {
1267 // Avoid writing a blank last line on end-of-string.
1268 if (*c != '\0' || !line.empty()) {
1269 // Add a command to echo this line.
1270 std::string cmd;
1271 if (color_name.empty() && !progress) {
1272 // Use the native echo command.
1273 cmd = cmStrCat("@echo ", this->EscapeForShell(line, false, true));
1274 } else {
1275 // Use cmake to echo the text in color.
1276 cmd = cmStrCat(
1277 "@$(CMAKE_COMMAND) -E cmake_echo_color \"--switch=$(COLOR)\" ",
1278 color_name);
1279 if (progress) {
1280 cmd = cmStrCat(cmd, "--progress-dir=",
1281 this->ConvertToOutputFormat(
1282 progress->Dir, cmOutputConverter::SHELL),
1283 " --progress-num=", progress->Arg, ' ');
1284 }
1285 cmd += this->EscapeForShell(line);
1286 }
1287 commands.emplace_back(std::move(cmd));
1288 }
1289

Callers 11

AppendCustomCommandMethod · 0.95
WriteLocalAllRulesMethod · 0.95
WriteExecutableRuleMethod · 0.80
operator()Method · 0.80
WriteObjectRuleFilesMethod · 0.80
WriteLibraryRulesMethod · 0.80
WriteHelpRuleMethod · 0.80

Calls 10

moveFunction · 0.85
GetToolSupportsColorMethod · 0.80
reserveMethod · 0.80
c_strMethod · 0.80
EscapeForShellMethod · 0.80
emplace_backMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
ConvertToOutputFormatMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected