diff options
author | Brad King <brad.king@kitware.com> | 2008-04-23 04:40:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-04-23 04:40:19 (GMT) |
commit | 85c983885b6c926e826e826c76c309cc738e1749 (patch) | |
tree | 02ca3ba724d1726da773437edcfb7e28fd9b81d7 | |
parent | bd09f6eabc90f03283509b26a2b57bdc42f8eeba (diff) | |
download | CMake-85c983885b6c926e826e826c76c309cc738e1749.zip CMake-85c983885b6c926e826e826c76c309cc738e1749.tar.gz CMake-85c983885b6c926e826e826c76c309cc738e1749.tar.bz2 |
BUG: Fix preservation of static libraries on original link lines.
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 74 | ||||
-rw-r--r-- | Source/cmComputeLinkDepends.h | 5 |
2 files changed, 73 insertions, 6 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 3632ff6..72dd198 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -143,8 +143,11 @@ The initial exploration of dependencies using a BFS associates an integer index with each link item. When the graph is built outgoing edges are sorted by this index. -This preserves the original link -order as much as possible subject to the dependencies. +This preserves the original link order as much as possible subject to +the dependencies. We then further preserve the original link line by +appending items to make sure all those that might be static libraries +appear in the order and multiplicity that they do in the original +line. After the initial exploration of the link interface tree, any transitive (dependent) shared libraries that were encountered and not @@ -237,8 +240,16 @@ cmComputeLinkDepends::Compute() this->DisplayConstraintGraph(); } - // Compute the final set of link entries. + // Compute the final ordering. this->OrderLinkEntires(); + this->PreserveOriginalEntries(); + + // Compute the final set of link entries. + for(std::vector<int>::const_iterator li = this->FinalLinkOrder.begin(); + li != this->FinalLinkOrder.end(); ++li) + { + this->FinalLinkEntries.push_back(this->EntryList[*li]); + } // Display the final set. if(this->DebugMode) @@ -546,6 +557,11 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, { this->EntryConstraintGraph[dependee_index].push_back(depender_index); } + else + { + // This is a direct dependency of the target being linked. + this->OriginalEntries.push_back(dependee_index); + } // Update the inferred dependencies for earlier items. for(std::map<int, DependSet>::iterator dsi = dependSets.begin(); @@ -789,7 +805,7 @@ void cmComputeLinkDepends::EmitComponent(NodeList const& nl) // Handle trivial components. if(nl.size() == 1) { - this->FinalLinkEntries.push_back(this->EntryList[nl[0]]); + this->FinalLinkOrder.push_back(nl[0]); return; } @@ -807,11 +823,11 @@ void cmComputeLinkDepends::EmitComponent(NodeList const& nl) // repeats needed. for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - this->FinalLinkEntries.push_back(this->EntryList[*ni]); + this->FinalLinkOrder.push_back(*ni); } for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - this->FinalLinkEntries.push_back(this->EntryList[*ni]); + this->FinalLinkOrder.push_back(*ni); } } @@ -854,3 +870,49 @@ void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item) } } } + +//---------------------------------------------------------------------------- +void cmComputeLinkDepends::PreserveOriginalEntries() +{ + // Skip the part of the input sequence that already appears in the + // output. + std::vector<int>::const_iterator in = this->OriginalEntries.begin(); + std::vector<int>::const_iterator out = this->FinalLinkOrder.begin(); + while(in != this->OriginalEntries.end() && + out != this->FinalLinkOrder.end()) + { + cmTarget* tgt = this->EntryList[*in].Target; + if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) + { + // Skip input items known to not be static libraries. + ++in; + } + else if(*in == *out) + { + // The input and output items match. Move on to the next items. + ++in; + ++out; + } + else + { + // The output item does not match the next input item. Skip it. + ++out; + } + } + + // Append the part of the input sequence that does not already + // appear in the output. + while(in != this->OriginalEntries.end()) + { + cmTarget* tgt = this->EntryList[*in].Target; + if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) + { + // Skip input items known to not be static libraries. + ++in; + } + else + { + this->FinalLinkOrder.push_back(*in++); + } + } +} diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 49e8d6b..3e42580 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -128,11 +128,16 @@ private: // Ordering algorithm. void OrderLinkEntires(); std::vector<char> ComponentVisited; + std::vector<int> FinalLinkOrder; void DisplayComponents(cmComputeComponentGraph const& ccg); void VisitComponent(cmComputeComponentGraph const& ccg, unsigned int i); void EmitComponent(NodeList const& nl); void DisplayFinalEntries(); + // Preservation of original link line. + std::vector<int> OriginalEntries; + void PreserveOriginalEntries(); + // Compatibility help. bool OldLinkDirMode; void CheckWrongConfigItem(std::string const& item); |