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

Method CreateCustomRulesMakefile

Source/cmGlobalXCodeGenerator.cxx:2396–2530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2394}
2395
2396void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
2397 char const* makefileBasename, cmGeneratorTarget* target,
2398 std::vector<cmCustomCommand> const& commands, std::string const& configName)
2399{
2400 std::string makefileName = cmStrCat(makefileBasename, configName);
2401 cmGeneratedFileStream makefileStream(makefileName);
2402 if (!makefileStream) {
2403 return;
2404 }
2405 makefileStream.SetCopyIfDifferent(true);
2406 makefileStream << "# Generated by CMake, DO NOT EDIT\n"
2407 "# Custom rules for "
2408 << target->GetName() << '\n';
2409
2410 // disable the implicit rules
2411 makefileStream << ".SUFFIXES: "
2412 "\n";
2413
2414 // have all depend on all outputs
2415 makefileStream << "all: ";
2416 std::map<cmCustomCommand const*, std::string> tname;
2417 int count = 0;
2418 for (auto const& command : commands) {
2419 cmCustomCommandGenerator ccg(command, configName,
2420 this->CurrentLocalGenerator);
2421 if (ccg.GetNumberOfCommands() > 0) {
2422 std::vector<std::string> const& outputs = ccg.GetOutputs();
2423 if (!outputs.empty()) {
2424 for (auto const& output : outputs) {
2425 makefileStream << "\\\n\t" << ConvertToMakefilePath(output);
2426 }
2427 } else {
2428 std::ostringstream str;
2429 str << "_buildpart_" << count++;
2430 tname[&ccg.GetCC()] = cmStrCat(target->GetName(), str.str());
2431 makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
2432 }
2433 }
2434 }
2435 makefileStream << "\n\n";
2436
2437 auto depfilesDirectory =
2438 cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
2439 "/CMakeFiles/d/");
2440
2441 for (auto const& command : commands) {
2442 cmCustomCommandGenerator ccg(
2443 command, configName, this->CurrentLocalGenerator, true, {},
2444 [this, &depfilesDirectory](std::string const& config,
2445 std::string const& file) -> std::string {
2446 return cmStrCat(
2447 depfilesDirectory,
2448 this->GetObjectId(cmXCodeObject::PBXShellScriptBuildPhase, file),
2449 '.', config, ".d");
2450 });
2451
2452 auto depfile = ccg.GetInternalDepfile();
2453 if (!depfile.empty()) {

Callers 1

Calls 15

GetObjectIdMethod · 0.95
ConvertToMakefilePathFunction · 0.85
moveFunction · 0.85
SetCopyIfDifferentMethod · 0.80
GetNumberOfCommandsMethod · 0.80
strMethod · 0.80
GetInternalDepfileMethod · 0.80
reserveMethod · 0.80
GetDependsMethod · 0.80
GetRealDependencyMethod · 0.80
emplace_backMethod · 0.80
EscapeForShellMethod · 0.80

Tested by

no test coverage detected