From a0ebd69b52dea77c5d8c718bcb7ba0c75ceb9d5f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 21 Oct 2015 21:49:41 +0200 Subject: Graphviz: Port to cmGeneratorTarget. --- Source/cmGraphVizWriter.cxx | 52 ++++++++++++++++++++++----------------------- Source/cmGraphVizWriter.h | 7 +++--- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index cc36c62..a63b6e3 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -17,7 +17,7 @@ -static const char* getShapeForTarget(const cmTarget* target) +static const char* getShapeForTarget(const cmGeneratorTarget* target) { if (!target) { @@ -163,7 +163,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) this->CollectTargetsAndLibs(); - for(std::map::const_iterator ptrIt = + for(std::map::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -214,7 +214,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) this->CollectTargetsAndLibs(); - for(std::map::const_iterator ptrIt = + for(std::map::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -268,7 +268,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName) std::set insertedConnections; std::set insertedNodes; - for(std::map::const_iterator ptrIt = + for(std::map::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -308,8 +308,8 @@ void cmGraphVizWriter::WriteConnections(const std::string& targetName, std::set& insertedConnections, cmGeneratedFileStream& str) const { - std::map::const_iterator targetPtrIt = - this->TargetPtrs.find(targetName); + std::map::const_iterator targetPtrIt + = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all { @@ -327,7 +327,7 @@ void cmGraphVizWriter::WriteConnections(const std::string& targetName, std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; const cmTarget::LinkLibraryVectorType* ll = - &(targetPtrIt->second->GetOriginalLinkLibraries()); + &(targetPtrIt->second->Target->GetOriginalLinkLibraries()); for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); llit != ll->end(); @@ -367,8 +367,8 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, std::set& insertedConnections, cmGeneratedFileStream& str) const { - std::map::const_iterator targetPtrIt = - this->TargetPtrs.find(targetName); + std::map::const_iterator targetPtrIt + = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all { @@ -386,8 +386,8 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; // now search who links against me - for(std::map::const_iterator dependerIt = - this->TargetPtrs.begin(); + for(std::map::const_iterator + dependerIt = this->TargetPtrs.begin(); dependerIt != this->TargetPtrs.end(); ++dependerIt) { @@ -404,7 +404,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, // Now we have a target, check whether it links against targetName. // If so, draw a connection, and then continue with dependers on that one. const cmTarget::LinkLibraryVectorType* ll = - &(dependerIt->second->GetOriginalLinkLibraries()); + &(dependerIt->second->Target->GetOriginalLinkLibraries()); for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); llit != ll->end(); @@ -448,7 +448,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, void cmGraphVizWriter::WriteNode(const std::string& targetName, - const cmTarget* target, + const cmGeneratorTarget* target, std::set& insertedNodes, cmGeneratedFileStream& str) const { @@ -488,12 +488,11 @@ int cmGraphVizWriter::CollectAllTargets() lit != this->LocalGenerators.end(); ++ lit ) { - const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); - for ( cmTargets::const_iterator tit = targets->begin(); - tit != targets->end(); - ++ tit ) + std::vector targets = (*lit)->GetGeneratorTargets(); + for ( std::vector::const_iterator it = + targets.begin(); it != targets.end(); ++it ) { - const char* realTargetName = tit->first.c_str(); + const char* realTargetName = (*it)->GetName().c_str(); if(this->IgnoreThisTarget(realTargetName)) { // Skip ignored targets @@ -503,7 +502,7 @@ int cmGraphVizWriter::CollectAllTargets() std::ostringstream ostr; ostr << this->GraphNodePrefix << cnt++; this->TargetNamesNodes[realTargetName] = ostr.str(); - this->TargetPtrs[realTargetName] = &tit->second; + this->TargetPtrs[realTargetName] = *it; } } @@ -519,19 +518,18 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) lit != this->LocalGenerators.end(); ++ lit ) { - const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); - for ( cmTargets::const_iterator tit = targets->begin(); - tit != targets->end(); - ++ tit ) + std::vector targets = (*lit)->GetGeneratorTargets(); + for ( std::vector::const_iterator it = + targets.begin(); it != targets.end(); ++it ) { - const char* realTargetName = tit->first.c_str(); + const char* realTargetName = (*it)->GetName().c_str(); if (this->IgnoreThisTarget(realTargetName)) { // Skip ignored targets continue; } const cmTarget::LinkLibraryVectorType* ll = - &(tit->second.GetOriginalLinkLibraries()); + &((*it)->Target->GetOriginalLinkLibraries()); for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); llit != ll->end(); ++ llit ) @@ -543,8 +541,8 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) continue; } - std::map::const_iterator tarIt = - this->TargetPtrs.find(libName); + std::map::const_iterator tarIt + = this->TargetPtrs.find(libName); if ( tarIt == this->TargetPtrs.end() ) { std::ostringstream ostr; diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 0a20e6e..90d31d3 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -14,9 +14,9 @@ #include "cmStandardIncludes.h" #include "cmLocalGenerator.h" #include "cmGeneratedFileStream.h" -#include "cmTarget.h" #include +class cmGeneratorTarget; /** This class implements writing files for graphviz (dot) for graphs * representing the dependencies between the targets in the project. */ @@ -54,7 +54,8 @@ protected: std::set& insertedConnections, cmGeneratedFileStream& str) const; - void WriteNode(const std::string& targetName, const cmTarget* target, + void WriteNode(const std::string& targetName, + const cmGeneratorTarget* target, std::set& insertedNodes, cmGeneratedFileStream& str) const; @@ -73,7 +74,7 @@ protected: const std::vector& LocalGenerators; - std::map TargetPtrs; + std::map TargetPtrs; // maps from the actual target names to node names in dot: std::map TargetNamesNodes; -- cgit v0.12