| 1716 | } |
| 1717 | |
| 1718 | std::pair<Json::Value, Target::FileSetDatabase> Target::DumpFileSets() |
| 1719 | { |
| 1720 | Json::Value fsJson = Json::nullValue; |
| 1721 | FileSetDatabase fsdb; |
| 1722 | |
| 1723 | // We record the visibility of each file set for later use when dumping |
| 1724 | // interface sources, which needs to map files to file set visibility |
| 1725 | // with only an index available. Those indexes match this vector. |
| 1726 | this->FileSetVisibilities.clear(); |
| 1727 | |
| 1728 | // Build the fileset database. |
| 1729 | auto const* tgt = this->GT->Target; |
| 1730 | auto const& fs_names = tgt->GetAllFileSetNames(); |
| 1731 | |
| 1732 | if (!fs_names.empty()) { |
| 1733 | fsJson = Json::arrayValue; |
| 1734 | size_t fsIndex = 0; |
| 1735 | for (auto const& fs_name : fs_names) { |
| 1736 | auto const* fs = tgt->GetFileSet(fs_name); |
| 1737 | if (!fs) { |
| 1738 | this->GT->Makefile->IssueMessage( |
| 1739 | MessageType::INTERNAL_ERROR, |
| 1740 | cmStrCat("Target \"", tgt->GetName(), |
| 1741 | "\" is tracked to have file set \"", fs_name, |
| 1742 | "\", but it was not found.")); |
| 1743 | continue; |
| 1744 | } |
| 1745 | |
| 1746 | cm::GenEx::Context context(this->GT->LocalGenerator, this->Config); |
| 1747 | |
| 1748 | auto fileEntries = fs->CompileFileEntries(); |
| 1749 | auto directoryEntries = fs->CompileDirectoryEntries(); |
| 1750 | |
| 1751 | auto directories = |
| 1752 | fs->EvaluateDirectoryEntries(directoryEntries, context, this->GT); |
| 1753 | |
| 1754 | fsJson.append(this->DumpFileSet(fs, directories)); |
| 1755 | this->FileSetVisibilities.push_back(fs->GetVisibility()); |
| 1756 | |
| 1757 | std::map<std::string, std::vector<std::string>> files_per_dirs; |
| 1758 | for (auto const& entry : fileEntries) { |
| 1759 | fs->EvaluateFileEntry(directories, files_per_dirs, entry, context, |
| 1760 | this->GT); |
| 1761 | } |
| 1762 | |
| 1763 | for (auto const& files_per_dir : files_per_dirs) { |
| 1764 | auto const& dir = files_per_dir.first; |
| 1765 | for (auto const& file : files_per_dir.second) { |
| 1766 | std::string sf_path; |
| 1767 | if (dir.empty() || cmSystemTools::FileIsFullPath(file)) { |
| 1768 | sf_path = file; |
| 1769 | } else { |
| 1770 | sf_path = cmStrCat(dir, '/', file); |
| 1771 | } |
| 1772 | fsdb[sf_path] = static_cast<Json::ArrayIndex>(fsIndex); |
| 1773 | } |
| 1774 | } |
| 1775 |
no test coverage detected