summaryrefslogtreecommitdiffstats
path: root/Source/cmGraphVizWriter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGraphVizWriter.cxx')
-rw-r--r--Source/cmGraphVizWriter.cxx53
1 files changed, 23 insertions, 30 deletions
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index c23156d..8a7728e 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGraphVizWriter.h"
+#include <algorithm>
#include <cctype>
#include <iostream>
#include <memory>
@@ -125,14 +126,6 @@ cmGraphVizWriter::cmGraphVizWriter(std::string const& fileName,
cmGraphVizWriter::~cmGraphVizWriter()
{
this->WriteFooter(this->GlobalFileStream);
-
- for (auto& fileStream : this->PerTargetFileStreams) {
- this->WriteFooter(*fileStream.second);
- }
-
- for (auto& fileStream : this->TargetDependersFileStreams) {
- this->WriteFooter(*fileStream.second);
- }
}
void cmGraphVizWriter::VisitGraph(std::string const&)
@@ -151,20 +144,10 @@ void cmGraphVizWriter::OnItem(cmLinkItem const& item)
++NextNodeId;
this->WriteNode(this->GlobalFileStream, item);
-
- if (this->GeneratePerTarget) {
- this->CreateTargetFile(this->PerTargetFileStreams, item);
- }
-
- if (this->GenerateDependers) {
- this->CreateTargetFile(this->TargetDependersFileStreams, item,
- ".dependers");
- }
}
-void cmGraphVizWriter::CreateTargetFile(FileStreamMap& fileStreamMap,
- cmLinkItem const& item,
- std::string const& fileNameSuffix)
+std::unique_ptr<cmGeneratedFileStream> cmGraphVizWriter::CreateTargetFile(
+ cmLinkItem const& item, std::string const& fileNameSuffix)
{
auto const pathSafeItemName = PathSafeString(item.AsStr());
auto const perTargetFileName =
@@ -175,7 +158,7 @@ void cmGraphVizWriter::CreateTargetFile(FileStreamMap& fileStreamMap,
this->WriteHeader(*perTargetFileStream, item.AsStr());
this->WriteNode(*perTargetFileStream, item);
- fileStreamMap.emplace(item.AsStr(), std::move(perTargetFileStream));
+ return perTargetFileStream;
}
void cmGraphVizWriter::OnDirectLink(cmLinkItem const& depender,
@@ -260,7 +243,7 @@ void cmGraphVizWriter::ReadSettings(
do { \
const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \
- (var) = mf.IsOn(cmakeDefinition); \
+ (var) = cmIsOn(value); \
} \
} while (false)
@@ -323,13 +306,12 @@ void cmGraphVizWriter::Write()
}
if (this->GeneratePerTarget) {
- WritePerTargetConnections<DependeesDir>(PerTargetConnections,
- PerTargetFileStreams);
+ WritePerTargetConnections<DependeesDir>(PerTargetConnections);
}
if (this->GenerateDependers) {
WritePerTargetConnections<DependersDir>(TargetDependersConnections,
- TargetDependersFileStreams);
+ ".dependers");
}
}
@@ -368,7 +350,7 @@ void cmGraphVizWriter::FindAllConnections(const ConnectionsMap& connectionMap,
template <typename DirFunc>
void cmGraphVizWriter::WritePerTargetConnections(
- const ConnectionsMap& connections, const FileStreamMap& streams)
+ const ConnectionsMap& connections, const std::string& fileNameSuffix)
{
// the per target connections must be extended by indirect dependencies
ConnectionsMap extendedConnections;
@@ -387,7 +369,9 @@ void cmGraphVizWriter::WritePerTargetConnections(
}
const Connections& cons = conPerTarget.second;
- auto fileStream = streams.at(rootItem.AsStr()).get();
+
+ std::unique_ptr<cmGeneratedFileStream> fileStream =
+ this->CreateTargetFile(rootItem, fileNameSuffix);
for (const Connection& con : cons) {
const cmLinkItem& src = DirFunc::src(con);
@@ -395,6 +379,8 @@ void cmGraphVizWriter::WritePerTargetConnections(
this->WriteNode(*fileStream, con.dst);
this->WriteConnection(*fileStream, src, dst, con.scopeType);
}
+
+ this->WriteFooter(*fileStream);
}
}
@@ -567,16 +553,23 @@ bool cmGraphVizWriter::TargetTypeEnabled(
std::string cmGraphVizWriter::ItemNameWithAliases(
std::string const& itemName) const
{
- auto nameWithAliases = itemName;
-
+ std::vector<std::string> items;
for (auto const& lg : this->GlobalGenerator->GetLocalGenerators()) {
for (auto const& aliasTargets : lg->GetMakefile()->GetAliasTargets()) {
if (aliasTargets.second == itemName) {
- nameWithAliases += "\\n(" + aliasTargets.first + ")";
+ items.push_back(aliasTargets.first);
}
}
}
+ std::sort(items.begin(), items.end());
+ items.erase(std::unique(items.begin(), items.end()), items.end());
+
+ auto nameWithAliases = itemName;
+ for(auto const& item : items) {
+ nameWithAliases += "\\n(" + item + ")";
+ }
+
return nameWithAliases;
}