MCPcopy Index your code
hub / github.com/Kitware/CMake / CreateRunScriptBuildPhase

Method CreateRunScriptBuildPhase

Source/cmGlobalXCodeGenerator.cxx:2073–2184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2071}
2072
2073cmXCodeObject* cmGlobalXCodeGenerator::CreateRunScriptBuildPhase(
2074 cmSourceFile const* sf, cmGeneratorTarget const* gt,
2075 cmCustomCommand const& cc)
2076{
2077 std::set<std::string> allConfigInputs;
2078 std::set<std::string> allConfigOutputs;
2079
2080 cmXCodeObject* buildPhase =
2081 this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase,
2082 cmStrCat(gt->GetName(), ':', sf->GetFullPath()));
2083
2084 auto depfilesDirectory = cmStrCat(
2085 gt->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/CMakeFiles/d/");
2086 auto depfilesPrefix = cmStrCat(depfilesDirectory, buildPhase->GetId(), '.');
2087
2088 std::string shellScript = "set -e\n";
2089 for (std::string const& configName : this->CurrentConfigurationTypes) {
2090 cmCustomCommandGenerator ccg(
2091 cc, configName, this->CurrentLocalGenerator, true, {},
2092 [&depfilesPrefix](std::string const& config, std::string const&)
2093 -> std::string { return cmStrCat(depfilesPrefix, config, ".d"); });
2094 std::vector<std::string> realDepends;
2095 realDepends.reserve(ccg.GetDepends().size());
2096 for (auto const& d : ccg.GetDepends()) {
2097 std::string dep;
2098 if (this->CurrentLocalGenerator->GetRealDependency(d, configName, dep)) {
2099 realDepends.emplace_back(std::move(dep));
2100 }
2101 }
2102
2103 allConfigInputs.insert(realDepends.begin(), realDepends.end());
2104 allConfigOutputs.insert(ccg.GetByproducts().begin(),
2105 ccg.GetByproducts().end());
2106 allConfigOutputs.insert(ccg.GetOutputs().begin(), ccg.GetOutputs().end());
2107
2108 shellScript =
2109 cmStrCat(shellScript, R"(if test "$CONFIGURATION" = ")", configName,
2110 "\"; then :\n", this->ConstructScript(ccg), "fi\n");
2111 }
2112
2113 if (!cc.GetDepfile().empty()) {
2114 buildPhase->AddAttribute(
2115 "dependencyFile",
2116 this->CreateString(cmStrCat(depfilesDirectory, buildPhase->GetId(),
2117 ".$(CONFIGURATION).d")));
2118 // to avoid spurious errors during first build, create empty dependency
2119 // files
2120 cmSystemTools::MakeDirectory(depfilesDirectory);
2121 for (std::string const& configName : this->CurrentConfigurationTypes) {
2122 auto file = cmStrCat(depfilesPrefix, configName, ".d");
2123 if (!cmSystemTools::FileExists(file)) {
2124 cmSystemTools::Touch(file, true);
2125 }
2126 }
2127 }
2128
2129 buildPhase->AddAttribute("buildActionMask",
2130 this->CreateString("2147483647"));

Callers 2

CreateCustomCommandsMethod · 0.95

Calls 15

CreateObjectMethod · 0.95
ConstructScriptMethod · 0.95
CreateStringMethod · 0.95
RelativeToBinaryMethod · 0.95
moveFunction · 0.85
reserveMethod · 0.80
GetDependsMethod · 0.80
GetRealDependencyMethod · 0.80
emplace_backMethod · 0.80
GetDepfileMethod · 0.80
AddUniqueObjectMethod · 0.80
GetSourceMethod · 0.80

Tested by

no test coverage detected