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

Method WriteCustomRule

Source/cmVisualStudio10TargetGenerator.cxx:1774–1909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1772}
1773
1774void cmVisualStudio10TargetGenerator::WriteCustomRule(
1775 Elem& e0, cmSourceFile const* source, cmCustomCommand const& command)
1776{
1777 std::string sourcePath = source->GetFullPath();
1778 // VS 10 will always rebuild a custom command attached to a .rule
1779 // file that doesn't exist so create the file explicitly.
1780 if (source->GetPropertyAsBool("__CMAKE_RULE")) {
1781 if (!cmSystemTools::FileExists(sourcePath)) {
1782 // Make sure the path exists for the file
1783 std::string path = cmSystemTools::GetFilenamePath(sourcePath);
1784 cmSystemTools::MakeDirectory(path);
1785 cmsys::ofstream fout(sourcePath.c_str());
1786 if (fout) {
1787 fout << "# generated from CMake\n";
1788 fout.flush();
1789 fout.close();
1790 // Force given file to have a very old timestamp, thus
1791 // preventing dependent rebuilds.
1792 this->ForceOld(sourcePath);
1793 } else {
1794 cmSystemTools::Error(cmStrCat("Could not create file: [", sourcePath,
1795 "] ",
1796 cmSystemTools::GetLastSystemError()));
1797 }
1798 }
1799 }
1800 cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
1801
1802 std::unique_ptr<Elem> spe1;
1803 std::unique_ptr<Elem> spe2;
1804 if (this->ProjectType != VsProjectType::csproj) {
1805 spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
1806 spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild");
1807 this->WriteSource(*spe2, source);
1808 spe2->SetHasElements();
1809 if (command.GetStdPipesUTF8()) {
1810 this->WriteStdOutEncodingUtf8(*spe2);
1811 }
1812 } else {
1813 Elem e1(e0, "ItemGroup");
1814 Elem e2(e1, "None");
1815 this->WriteSource(e2, source);
1816 e2.SetHasElements();
1817 }
1818 for (std::string const& c : this->Configurations) {
1819 cmCustomCommandGenerator ccg(command, c, lg, true);
1820 std::string comment = lg->ConstructComment(ccg);
1821 comment = cmVS10EscapeComment(comment);
1822 std::string script = lg->ConstructScript(ccg);
1823 bool symbolic = false;
1824 // input files for custom command
1825 std::stringstream additional_inputs;
1826 {
1827 char const* sep = "";
1828 if (this->ProjectType == VsProjectType::csproj) {
1829 // csproj files do not attach the command to a specific file
1830 // so the primary input must be listed explicitly.
1831 additional_inputs << source->GetFullPath();

Callers 2

WriteCustomCommandsMethod · 0.95
WriteCustomCommandMethod · 0.95

Calls 15

ForceOldMethod · 0.95
WriteSourceMethod · 0.95
WriteCustomRuleCSharpMethod · 0.95
WriteCustomRuleCppMethod · 0.95
cmVS10EscapeCommentFunction · 0.85
ConvertToWindowsSlashFunction · 0.85
c_strMethod · 0.80
SetHasElementsMethod · 0.80
GetStdPipesUTF8Method · 0.80
ConstructCommentMethod · 0.80
GetDependsMethod · 0.80

Tested by

no test coverage detected