Helper function to create dependency scanning rule that may or may not perform explicit preprocessing too.
| 584 | // Helper function to create dependency scanning rule that may or may |
| 585 | // not perform explicit preprocessing too. |
| 586 | cmNinjaRule GetScanRule( |
| 587 | std::string const& ruleName, std::string const& ppFileName, |
| 588 | std::string const& deptype, |
| 589 | cmRulePlaceholderExpander::RuleVariables const& vars, |
| 590 | std::string const& responseFlag, std::string const& flags, |
| 591 | cmRulePlaceholderExpander* const rulePlaceholderExpander, |
| 592 | cmLocalNinjaGenerator* generator, std::vector<std::string> scanCmds, |
| 593 | std::string const& outputConfig) |
| 594 | { |
| 595 | cmNinjaRule rule(ruleName); |
| 596 | // Scanning always uses a depfile for preprocessor dependencies. |
| 597 | if (deptype == "msvc"_s) { |
| 598 | rule.DepType = deptype; |
| 599 | rule.DepFile.clear(); |
| 600 | } else { |
| 601 | rule.DepType.clear(); // no deps= for multiple outputs |
| 602 | rule.DepFile = "$DEP_FILE"; |
| 603 | } |
| 604 | |
| 605 | cmRulePlaceholderExpander::RuleVariables scanVars; |
| 606 | scanVars.CMTargetName = vars.CMTargetName; |
| 607 | scanVars.CMTargetType = vars.CMTargetType; |
| 608 | scanVars.Language = vars.Language; |
| 609 | scanVars.Object = "$OBJ_FILE"; |
| 610 | scanVars.PreprocessedSource = ppFileName.c_str(); |
| 611 | scanVars.DynDepFile = "$DYNDEP_INTERMEDIATE_FILE"; |
| 612 | scanVars.DependencyFile = rule.DepFile.c_str(); |
| 613 | scanVars.DependencyTarget = "$out"; |
| 614 | scanVars.Config = vars.Config; |
| 615 | |
| 616 | // Scanning needs the same preprocessor settings as direct compilation would. |
| 617 | scanVars.Source = vars.Source; |
| 618 | scanVars.Defines = vars.Defines; |
| 619 | scanVars.Includes = vars.Includes; |
| 620 | |
| 621 | // Scanning needs the compilation flags too. |
| 622 | std::string scanFlags = flags; |
| 623 | |
| 624 | // If using a response file, move defines, includes, and flags into it. |
| 625 | if (!responseFlag.empty()) { |
| 626 | rule.RspFile = "$RSP_FILE"; |
| 627 | rule.RspContent = |
| 628 | cmStrCat(' ', scanVars.Defines, ' ', scanVars.Includes, ' ', scanFlags); |
| 629 | scanFlags = cmStrCat(responseFlag, rule.RspFile); |
| 630 | scanVars.Defines = ""; |
| 631 | scanVars.Includes = ""; |
| 632 | } |
| 633 | |
| 634 | scanVars.Flags = scanFlags.c_str(); |
| 635 | |
| 636 | // Rule for scanning a source file. |
| 637 | for (std::string& scanCmd : scanCmds) { |
| 638 | rulePlaceholderExpander->ExpandRuleVariables(generator, scanCmd, scanVars); |
| 639 | } |
| 640 | rule.Command = |
| 641 | generator->BuildCommandLine(scanCmds, outputConfig, outputConfig); |
| 642 | |
| 643 | return rule; |
no test coverage detected
searching dependent graphs…