summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Rohmen <s.rohmen@gmx.de>2020-07-31 20:26:08 (GMT)
committerStephan Rohmen <s.rohmen@gmx.de>2020-07-31 20:26:08 (GMT)
commit57f250dcc0d2b7130194f151462e9b0552d66b09 (patch)
tree6ae1367b9fc3a60431e224b5e4dd64bb8a8d1fe7
parent383090bf591e82d5488bd3454ca4c40ceaf575df (diff)
downloadCMake-57f250dcc0d2b7130194f151462e9b0552d66b09.zip
CMake-57f250dcc0d2b7130194f151462e9b0552d66b09.tar.gz
CMake-57f250dcc0d2b7130194f151462e9b0552d66b09.tar.bz2
Graphviz: Fix issue with too many open file streams on Windows platform
Fixes #20931
-rw-r--r--Source/cmGraphVizWriter.cxx37
-rw-r--r--Source/cmGraphVizWriter.h11
2 files changed, 14 insertions, 34 deletions
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 8e9abf8..570f4ea 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -125,14 +125,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 +143,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 +157,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,
@@ -323,13 +305,12 @@ void cmGraphVizWriter::Write()
}
if (this->GeneratePerTarget) {
- WritePerTargetConnections<DependeesDir>(PerTargetConnections,
- PerTargetFileStreams);
+ WritePerTargetConnections<DependeesDir>(PerTargetConnections);
}
if (this->GenerateDependers) {
WritePerTargetConnections<DependersDir>(TargetDependersConnections,
- TargetDependersFileStreams);
+ ".dependers");
}
}
@@ -368,7 +349,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 +368,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 +378,8 @@ void cmGraphVizWriter::WritePerTargetConnections(
this->WriteNode(*fileStream, con.dst);
this->WriteConnection(*fileStream, src, dst, con.scopeType);
}
+
+ this->WriteFooter(*fileStream);
}
}
diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h
index 9766068..d1300ac 100644
--- a/Source/cmGraphVizWriter.h
+++ b/Source/cmGraphVizWriter.h
@@ -46,9 +46,6 @@ public:
void Write();
private:
- using FileStreamMap =
- std::map<std::string, std::unique_ptr<cmGeneratedFileStream>>;
-
struct Connection
{
Connection(cmLinkItem s, cmLinkItem d, std::string scope)
@@ -76,8 +73,8 @@ private:
void WriteNode(cmGeneratedFileStream& fs, cmLinkItem const& item);
- void CreateTargetFile(FileStreamMap& fileStreamMap, cmLinkItem const& target,
- std::string const& fileNameSuffix = "");
+ std::unique_ptr<cmGeneratedFileStream> CreateTargetFile(
+ cmLinkItem const& target, std::string const& fileNameSuffix = "");
void WriteConnection(cmGeneratedFileStream& fs,
cmLinkItem const& dependerTargetName,
@@ -95,7 +92,7 @@ private:
template <typename DirFunc>
void WritePerTargetConnections(const ConnectionsMap& connections,
- const FileStreamMap& streams);
+ const std::string& fileNameSuffix = "");
bool ItemExcluded(cmLinkItem const& item);
bool ItemNameFilteredOut(std::string const& itemName);
@@ -111,8 +108,6 @@ private:
std::string FileName;
cmGeneratedFileStream GlobalFileStream;
- FileStreamMap PerTargetFileStreams;
- FileStreamMap TargetDependersFileStreams;
ConnectionsMap PerTargetConnections;
ConnectionsMap TargetDependersConnections;