| 2071 | } |
| 2072 | |
| 2073 | cmXCodeObject* 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")); |
no test coverage detected