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

Method GenerateCommands

Source/cmFastbuildTargetGenerator.cxx:527–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
528 FastbuildBuildStep buildStep)
529{
530 FastbuildExecNodes execs;
531 execs.Alias.Name = GetUtilityAliasFromBuildStep(buildStep);
532
533 std::vector<cmCustomCommand> commands;
534 if (buildStep == FastbuildBuildStep::PRE_BUILD) {
535 commands = GeneratorTarget->GetPreBuildCommands();
536 LogMessage("STEP: PRE_BUILD");
537 } else if (buildStep == FastbuildBuildStep::PRE_LINK) {
538 commands = GeneratorTarget->GetPreLinkCommands();
539 LogMessage("STEP: PRE_LINK");
540 } else if (buildStep == FastbuildBuildStep::POST_BUILD) {
541 commands = GeneratorTarget->GetPostBuildCommands();
542 LogMessage("STEP: POST_BUILD");
543 } else {
544 LogMessage("STEP: ALL CUSTOM COMMANDS");
545 std::vector<cmSourceFile const*> customCommands;
546 GeneratorTarget->GetCustomCommands(customCommands, Config);
547 for (cmSourceFile const* source : customCommands) {
548 cmCustomCommand const* cmd = source->GetCustomCommand();
549 if (!cmd->GetCommandLines().empty()) {
550 commands.emplace_back(*cmd);
551 }
552 }
553 }
554 LogMessage(cmStrCat("Number of custom commands: ", commands.size()));
555 for (cmCustomCommand const& customCommand : commands) {
556 cmCustomCommandGenerator ccg(customCommand, Config, LocalCommonGenerator);
557 std::string launcher = this->MakeCustomLauncher(ccg);
558
559 std::string const execName =
560 GetCustomCommandTargetName(customCommand, buildStep);
561
562 std::vector<std::string> cmdLines;
563 if (ccg.GetNumberOfCommands() > 0) {
564 cmdLines.push_back(GetCdCommand(ccg));
565 }
566
567 // Since we are not using FASTBuild Exec nodes natively, we need to
568 // have shell specific escape.
569 this->LocalGenerator->GetState()->SetFastbuildMake(false);
570 // To avoid replacing $ with $$ in the command line.
571 this->LocalGenerator->SetLinkScriptShell(true);
572 for (unsigned j = 0; j != ccg.GetNumberOfCommands(); ++j) {
573 std::string const command = ccg.GetCommand(j);
574 // Tested in "CustomCommand" ("empty_command") test.
575 if (!command.empty()) {
576
577 cmdLines.emplace_back(launcher +
578 this->LocalGenerator->ConvertToOutputFormat(
579 command, cmOutputConverter::SHELL));
580
581 std::string& cmd = cmdLines.back();
582 ccg.AppendArguments(j, cmd);
583 ReplaceProblematicMakeVars(cmd);
584 LogMessage("cmCustomCommandLine: " + cmd);

Callers

nothing calls this directly

Calls 15

MakeCustomLauncherMethod · 0.95
GetGlobalGeneratorMethod · 0.95
to_stringFunction · 0.85
moveFunction · 0.85
GetCustomCommandsMethod · 0.80
GetCustomCommandMethod · 0.80
emplace_backMethod · 0.80
GetNumberOfCommandsMethod · 0.80
push_backMethod · 0.80
SetFastbuildMakeMethod · 0.80
SetLinkScriptShellMethod · 0.80

Tested by

no test coverage detected