| 1736 | } |
| 1737 | |
| 1738 | void cmMakefileTargetGenerator::GenerateCustomRuleFile( |
| 1739 | cmCustomCommandGenerator const& ccg) |
| 1740 | { |
| 1741 | // Collect the commands. |
| 1742 | std::vector<std::string> commands; |
| 1743 | std::string comment = this->LocalGenerator->ConstructComment(ccg); |
| 1744 | if (!comment.empty()) { |
| 1745 | // add in a progress call if needed |
| 1746 | this->NumberOfProgressActions++; |
| 1747 | if (!this->NoRuleMessages) { |
| 1748 | cmLocalUnixMakefileGenerator3::EchoProgress progress; |
| 1749 | this->MakeEchoProgress(progress); |
| 1750 | this->LocalGenerator->AppendEcho( |
| 1751 | commands, comment, cmLocalUnixMakefileGenerator3::EchoGenerate, |
| 1752 | &progress); |
| 1753 | } |
| 1754 | } |
| 1755 | |
| 1756 | // Now append the actual user-specified commands. |
| 1757 | std::ostringstream content; |
| 1758 | this->LocalGenerator->AppendCustomCommand( |
| 1759 | commands, ccg, this->GeneratorTarget, |
| 1760 | this->LocalGenerator->GetBinaryDirectory(), false, &content); |
| 1761 | |
| 1762 | // Collect the dependencies. |
| 1763 | std::vector<std::string> depends; |
| 1764 | this->LocalGenerator->AppendCustomDepend(depends, ccg); |
| 1765 | |
| 1766 | if (!ccg.GetCC().GetDepfile().empty()) { |
| 1767 | // Add dependency over timestamp file for dependencies management |
| 1768 | auto dependTimestamp = this->LocalGenerator->MaybeRelativeToTopBinDir( |
| 1769 | cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.ts")); |
| 1770 | |
| 1771 | depends.emplace_back(std::move(dependTimestamp)); |
| 1772 | } |
| 1773 | |
| 1774 | // Write the rule. |
| 1775 | std::vector<std::string> const& outputs = ccg.GetOutputs(); |
| 1776 | bool const symbolic = this->WriteMakeRule(*this->BuildFileStream, nullptr, |
| 1777 | outputs, depends, commands); |
| 1778 | |
| 1779 | // Symbolic inputs are not expected to exist, so add dummy rules. |
| 1780 | if (this->CMP0113New && !depends.empty()) { |
| 1781 | std::vector<std::string> no_depends; |
| 1782 | std::vector<std::string> no_commands; |
| 1783 | for (std::string const& dep : depends) { |
| 1784 | if (cmSourceFile* dsf = |
| 1785 | this->Makefile->GetSource(dep, cmSourceFileLocationKind::Known)) { |
| 1786 | if (dsf->GetPropertyAsBool("SYMBOLIC")) { |
| 1787 | this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, |
| 1788 | dep, no_depends, no_commands, |
| 1789 | true); |
| 1790 | } |
| 1791 | } |
| 1792 | } |
| 1793 | } |
| 1794 | |
| 1795 | // If the rule has changed make sure the output is rebuilt. |
no test coverage detected