| 2237 | } |
| 2238 | |
| 2239 | void cmNinjaTargetGenerator::ExportObjectCompileCommand( |
| 2240 | std::string const& language, std::string const& sourceFileName, |
| 2241 | std::string const& objectDir, std::string const& targetSupportDir, |
| 2242 | std::string const& objectFileName, std::string const& objectFileDir, |
| 2243 | std::string const& flags, std::string const& defines, |
| 2244 | std::string const& includes, std::string const& targetCompilePdb, |
| 2245 | std::string const& targetPdb, std::string const& outputConfig, |
| 2246 | WithScanning withScanning) |
| 2247 | { |
| 2248 | if (!this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS")) { |
| 2249 | return; |
| 2250 | } |
| 2251 | |
| 2252 | cmRulePlaceholderExpander::RuleVariables compileObjectVars; |
| 2253 | compileObjectVars.Language = language.c_str(); |
| 2254 | |
| 2255 | std::string escapedSourceFileName = sourceFileName; |
| 2256 | |
| 2257 | if (!cmSystemTools::FileIsFullPath(sourceFileName)) { |
| 2258 | escapedSourceFileName = |
| 2259 | cmSystemTools::CollapseFullPath(escapedSourceFileName, |
| 2260 | this->GetGlobalGenerator() |
| 2261 | ->GetCMakeInstance() |
| 2262 | ->GetHomeOutputDirectory()); |
| 2263 | } |
| 2264 | |
| 2265 | escapedSourceFileName = this->LocalGenerator->ConvertToOutputFormat( |
| 2266 | escapedSourceFileName, cmOutputConverter::SHELL); |
| 2267 | |
| 2268 | std::string fullFlags = flags; |
| 2269 | if (withScanning == WithScanning::Yes) { |
| 2270 | std::string const modmapFormatVar = |
| 2271 | cmStrCat("CMAKE_", language, "_MODULE_MAP_FORMAT"); |
| 2272 | std::string const modmapFormat = |
| 2273 | this->Makefile->GetSafeDefinition(modmapFormatVar); |
| 2274 | if (!modmapFormat.empty()) { |
| 2275 | std::string modmapFlags = this->GetMakefile()->GetRequiredDefinition( |
| 2276 | cmStrCat("CMAKE_", language, "_MODULE_MAP_FLAG")); |
| 2277 | // XXX(modmap): If changing this path construction, change |
| 2278 | // `cmGlobalNinjaGenerator::WriteDyndep` and |
| 2279 | // `cmNinjaTargetGenerator::WriteObjectBuildStatement` to expect the |
| 2280 | // corresponding file path. |
| 2281 | cmSystemTools::ReplaceString(modmapFlags, "<MODULE_MAP_FILE>", |
| 2282 | cmStrCat(objectFileName, ".modmap")); |
| 2283 | fullFlags += cmStrCat(' ', modmapFlags); |
| 2284 | } |
| 2285 | } |
| 2286 | |
| 2287 | compileObjectVars.Source = escapedSourceFileName.c_str(); |
| 2288 | std::string escapedObjectFileName = |
| 2289 | this->LocalGenerator->ConvertToOutputFormat(objectFileName, |
| 2290 | cmOutputConverter::SHELL); |
| 2291 | compileObjectVars.Object = escapedObjectFileName.c_str(); |
| 2292 | compileObjectVars.ObjectDir = objectDir.c_str(); |
| 2293 | compileObjectVars.TargetSupportDir = targetSupportDir.c_str(); |
| 2294 | compileObjectVars.ObjectFileDir = objectFileDir.c_str(); |
| 2295 | compileObjectVars.Flags = fullFlags.c_str(); |
| 2296 | compileObjectVars.Defines = defines.c_str(); |
no test coverage detected