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

Function GetScanBuildStatement

Source/cmNinjaTargetGenerator.cxx:1309–1391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1307
1308namespace {
1309cmNinjaBuild GetScanBuildStatement(std::string const& ruleName,
1310 std::string const& ppFileName,
1311 bool compilePP, bool compilePPWithDefines,
1312 bool compilationPreprocesses,
1313 cmNinjaBuild& objBuild, cmNinjaVars& vars,
1314 std::string const& objectFileName,
1315 cmNinjaTargetGenerator* tg)
1316{
1317 cmNinjaBuild scanBuild(ruleName);
1318
1319 if (compilePP) {
1320 // Move compilation dependencies to the scan/preprocessing build statement.
1321 std::swap(scanBuild.ExplicitDeps, objBuild.ExplicitDeps);
1322 std::swap(scanBuild.ImplicitDeps, objBuild.ImplicitDeps);
1323 std::swap(scanBuild.OrderOnlyDeps, objBuild.OrderOnlyDeps);
1324 std::swap(scanBuild.Variables["IN_ABS"], vars["IN_ABS"]);
1325
1326 // The actual compilation will now use the preprocessed source.
1327 objBuild.ExplicitDeps.push_back(ppFileName);
1328 } else {
1329 // Copy compilation dependencies to the scan/preprocessing build statement.
1330 scanBuild.ExplicitDeps = objBuild.ExplicitDeps;
1331 scanBuild.ImplicitDeps = objBuild.ImplicitDeps;
1332 scanBuild.OrderOnlyDeps = objBuild.OrderOnlyDeps;
1333 scanBuild.Variables["IN_ABS"] = vars["IN_ABS"];
1334 }
1335
1336 // Scanning and compilation generally use the same flags.
1337 scanBuild.Variables["FLAGS"] = vars["FLAGS"];
1338
1339 if (compilePP && !compilePPWithDefines) {
1340 // Move preprocessor definitions to the scan/preprocessor build statement.
1341 std::swap(scanBuild.Variables["DEFINES"], vars["DEFINES"]);
1342 } else {
1343 // Copy preprocessor definitions to the scan/preprocessor build statement.
1344 scanBuild.Variables["DEFINES"] = vars["DEFINES"];
1345 }
1346
1347 // Copy include directories to the preprocessor build statement. The
1348 // Fortran compilation build statement still needs them for the INCLUDE
1349 // directive.
1350 scanBuild.Variables["INCLUDES"] = vars["INCLUDES"];
1351
1352 // Tell dependency scanner the object file that will result from
1353 // compiling the source.
1354 scanBuild.Variables["OBJ_FILE"] =
1355 tg->ConvertToOutputFormatForShell(objectFileName);
1356
1357 // Tell dependency scanner where to store dyndep intermediate results.
1358 std::string ddiFileName = cmStrCat(objectFileName, ".ddi");
1359 scanBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] =
1360 tg->ConvertToOutputFormatForShell(ddiFileName);
1361 scanBuild.RspFile = cmStrCat(ddiFileName, ".rsp");
1362
1363 // Outputs of the scan/preprocessor build statement.
1364 if (compilePP) {
1365 scanBuild.Outputs.push_back(ppFileName);
1366 scanBuild.ImplicitOuts.push_back(ddiFileName);

Calls 8

push_backMethod · 0.80
emplace_backMethod · 0.80
AddDepfileBindingMethod · 0.80
RemoveDepfileBindingMethod · 0.80
swapFunction · 0.70
cmStrCatFunction · 0.70
frontMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…