mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-21 22:50:26 -06:00
cmComputeComponentGraph: use size_t for component indices
This avoids using casts everywhere when dealing with the sizes.
This commit is contained in:
@@ -4,8 +4,11 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
const int cmComputeComponentGraph::INVALID_COMPONENT = -1;
|
const size_t cmComputeComponentGraph::INVALID_COMPONENT =
|
||||||
|
std::numeric_limits<size_t>::max();
|
||||||
|
|
||||||
cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input)
|
cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input)
|
||||||
: InputGraph(input)
|
: InputGraph(input)
|
||||||
@@ -27,7 +30,7 @@ void cmComputeComponentGraph::Compute()
|
|||||||
|
|
||||||
void cmComputeComponentGraph::Tarjan()
|
void cmComputeComponentGraph::Tarjan()
|
||||||
{
|
{
|
||||||
int n = static_cast<int>(this->InputGraph.size());
|
size_t n = this->InputGraph.size();
|
||||||
TarjanEntry entry = { 0, 0 };
|
TarjanEntry entry = { 0, 0 };
|
||||||
this->TarjanEntries.resize(0);
|
this->TarjanEntries.resize(0);
|
||||||
this->TarjanEntries.resize(n, entry);
|
this->TarjanEntries.resize(n, entry);
|
||||||
@@ -36,7 +39,7 @@ void cmComputeComponentGraph::Tarjan()
|
|||||||
this->TarjanWalkId = 0;
|
this->TarjanWalkId = 0;
|
||||||
this->TarjanVisited.resize(0);
|
this->TarjanVisited.resize(0);
|
||||||
this->TarjanVisited.resize(n, 0);
|
this->TarjanVisited.resize(n, 0);
|
||||||
for (int i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
// Start a new DFS from this node if it has never been visited.
|
// Start a new DFS from this node if it has never been visited.
|
||||||
if (!this->TarjanVisited[i]) {
|
if (!this->TarjanVisited[i]) {
|
||||||
assert(this->TarjanStack.empty());
|
assert(this->TarjanStack.empty());
|
||||||
@@ -47,7 +50,7 @@ void cmComputeComponentGraph::Tarjan()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeComponentGraph::TarjanVisit(int i)
|
void cmComputeComponentGraph::TarjanVisit(size_t i)
|
||||||
{
|
{
|
||||||
// We are now visiting this node.
|
// We are now visiting this node.
|
||||||
this->TarjanVisited[i] = this->TarjanWalkId;
|
this->TarjanVisited[i] = this->TarjanWalkId;
|
||||||
@@ -61,7 +64,7 @@ void cmComputeComponentGraph::TarjanVisit(int i)
|
|||||||
// Follow outgoing edges.
|
// Follow outgoing edges.
|
||||||
EdgeList const& nl = this->InputGraph[i];
|
EdgeList const& nl = this->InputGraph[i];
|
||||||
for (cmGraphEdge const& ni : nl) {
|
for (cmGraphEdge const& ni : nl) {
|
||||||
int j = ni;
|
size_t j = ni;
|
||||||
|
|
||||||
// Ignore edges to nodes that have been reached by a previous DFS
|
// Ignore edges to nodes that have been reached by a previous DFS
|
||||||
// walk. Since we did not reach the current node from that walk
|
// walk. Since we did not reach the current node from that walk
|
||||||
@@ -90,12 +93,12 @@ void cmComputeComponentGraph::TarjanVisit(int i)
|
|||||||
// Check if we have found a component.
|
// Check if we have found a component.
|
||||||
if (this->TarjanEntries[i].Root == i) {
|
if (this->TarjanEntries[i].Root == i) {
|
||||||
// Yes. Create it.
|
// Yes. Create it.
|
||||||
int c = static_cast<int>(this->Components.size());
|
size_t c = this->Components.size();
|
||||||
this->Components.emplace_back();
|
this->Components.emplace_back();
|
||||||
NodeList& component = this->Components[c];
|
NodeList& component = this->Components[c];
|
||||||
|
|
||||||
// Populate the component list.
|
// Populate the component list.
|
||||||
int j;
|
size_t j;
|
||||||
do {
|
do {
|
||||||
// Get the next member of the component.
|
// Get the next member of the component.
|
||||||
j = this->TarjanStack.top();
|
j = this->TarjanStack.top();
|
||||||
@@ -118,13 +121,13 @@ void cmComputeComponentGraph::TransferEdges()
|
|||||||
{
|
{
|
||||||
// Map inter-component edges in the original graph to edges in the
|
// Map inter-component edges in the original graph to edges in the
|
||||||
// component graph.
|
// component graph.
|
||||||
int n = static_cast<int>(this->InputGraph.size());
|
size_t n = this->InputGraph.size();
|
||||||
for (int i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
int i_component = this->TarjanComponents[i];
|
size_t i_component = this->TarjanComponents[i];
|
||||||
EdgeList const& nl = this->InputGraph[i];
|
EdgeList const& nl = this->InputGraph[i];
|
||||||
for (cmGraphEdge const& ni : nl) {
|
for (cmGraphEdge const& ni : nl) {
|
||||||
int j = ni;
|
size_t j = ni;
|
||||||
int j_component = this->TarjanComponents[j];
|
size_t j_component = this->TarjanComponents[j];
|
||||||
if (i_component != j_component) {
|
if (i_component != j_component) {
|
||||||
// We do not attempt to combine duplicate edges, but instead
|
// We do not attempt to combine duplicate edges, but instead
|
||||||
// store the inter-component edges with suitable multiplicity.
|
// store the inter-component edges with suitable multiplicity.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ public:
|
|||||||
|
|
||||||
/** Get the adjacency list of the component graph. */
|
/** Get the adjacency list of the component graph. */
|
||||||
Graph const& GetComponentGraph() const { return this->ComponentGraph; }
|
Graph const& GetComponentGraph() const { return this->ComponentGraph; }
|
||||||
EdgeList const& GetComponentGraphEdges(int c) const
|
EdgeList const& GetComponentGraphEdges(size_t c) const
|
||||||
{
|
{
|
||||||
return this->ComponentGraph[c];
|
return this->ComponentGraph[c];
|
||||||
}
|
}
|
||||||
@@ -45,15 +46,15 @@ public:
|
|||||||
{
|
{
|
||||||
return this->Components;
|
return this->Components;
|
||||||
}
|
}
|
||||||
NodeList const& GetComponent(int c) const { return this->Components[c]; }
|
NodeList const& GetComponent(size_t c) const { return this->Components[c]; }
|
||||||
|
|
||||||
/** Get map from original node index to component index. */
|
/** Get map from original node index to component index. */
|
||||||
std::vector<int> const& GetComponentMap() const
|
std::vector<size_t> const& GetComponentMap() const
|
||||||
{
|
{
|
||||||
return this->TarjanComponents;
|
return this->TarjanComponents;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int INVALID_COMPONENT;
|
static const size_t INVALID_COMPONENT;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TransferEdges();
|
void TransferEdges();
|
||||||
@@ -64,18 +65,18 @@ private:
|
|||||||
// Tarjan's algorithm.
|
// Tarjan's algorithm.
|
||||||
struct TarjanEntry
|
struct TarjanEntry
|
||||||
{
|
{
|
||||||
int Root;
|
size_t Root;
|
||||||
int VisitIndex;
|
size_t VisitIndex;
|
||||||
};
|
};
|
||||||
std::vector<int> TarjanVisited;
|
std::vector<size_t> TarjanVisited;
|
||||||
std::vector<int> TarjanComponents;
|
std::vector<size_t> TarjanComponents;
|
||||||
std::vector<TarjanEntry> TarjanEntries;
|
std::vector<TarjanEntry> TarjanEntries;
|
||||||
std::vector<NodeList> Components;
|
std::vector<NodeList> Components;
|
||||||
std::stack<int> TarjanStack;
|
std::stack<size_t> TarjanStack;
|
||||||
int TarjanWalkId;
|
size_t TarjanWalkId;
|
||||||
int TarjanIndex;
|
size_t TarjanIndex;
|
||||||
void Tarjan();
|
void Tarjan();
|
||||||
void TarjanVisit(int i);
|
void TarjanVisit(size_t i);
|
||||||
|
|
||||||
// Connected components.
|
// Connected components.
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -375,8 +376,8 @@ cmComputeLinkDepends::Compute()
|
|||||||
// Compute the final set of link entries.
|
// Compute the final set of link entries.
|
||||||
// Iterate in reverse order so we can keep only the last occurrence
|
// Iterate in reverse order so we can keep only the last occurrence
|
||||||
// of a shared library.
|
// of a shared library.
|
||||||
std::set<int> emitted;
|
std::set<size_t> emitted;
|
||||||
for (int i : cmReverseRange(this->FinalLinkOrder)) {
|
for (size_t i : cmReverseRange(this->FinalLinkOrder)) {
|
||||||
LinkEntry const& e = this->EntryList[i];
|
LinkEntry const& e = this->EntryList[i];
|
||||||
cmGeneratorTarget const* t = e.Target;
|
cmGeneratorTarget const* t = e.Target;
|
||||||
// Entries that we know the linker will re-use do not need to be repeated.
|
// Entries that we know the linker will re-use do not need to be repeated.
|
||||||
@@ -388,7 +389,7 @@ cmComputeLinkDepends::Compute()
|
|||||||
// Place explicitly linked object files in the front. The linker will
|
// Place explicitly linked object files in the front. The linker will
|
||||||
// always use them anyway, and they may depend on symbols from libraries.
|
// always use them anyway, and they may depend on symbols from libraries.
|
||||||
// Append in reverse order since we reverse the final order below.
|
// Append in reverse order since we reverse the final order below.
|
||||||
for (int i : cmReverseRange(this->ObjectEntries)) {
|
for (size_t i : cmReverseRange(this->ObjectEntries)) {
|
||||||
this->FinalLinkEntries.emplace_back(this->EntryList[i]);
|
this->FinalLinkEntries.emplace_back(this->EntryList[i]);
|
||||||
}
|
}
|
||||||
// Reverse the resulting order since we iterated in reverse.
|
// Reverse the resulting order since we iterated in reverse.
|
||||||
@@ -432,11 +433,11 @@ std::string const& cmComputeLinkDepends::GetCurrentFeature(
|
|||||||
return it == this->LinkLibraryOverride.end() ? defaultFeature : it->second;
|
return it == this->LinkLibraryOverride.end() ? defaultFeature : it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::map<cmLinkItem, int>::iterator, bool>
|
std::pair<std::map<cmLinkItem, size_t>::iterator, bool>
|
||||||
cmComputeLinkDepends::AllocateLinkEntry(cmLinkItem const& item)
|
cmComputeLinkDepends::AllocateLinkEntry(cmLinkItem const& item)
|
||||||
{
|
{
|
||||||
std::map<cmLinkItem, int>::value_type index_entry(
|
std::map<cmLinkItem, size_t>::value_type index_entry(
|
||||||
item, static_cast<int>(this->EntryList.size()));
|
item, static_cast<size_t>(this->EntryList.size()));
|
||||||
auto lei = this->LinkEntryIndex.insert(index_entry);
|
auto lei = this->LinkEntryIndex.insert(index_entry);
|
||||||
if (lei.second) {
|
if (lei.second) {
|
||||||
this->EntryList.emplace_back();
|
this->EntryList.emplace_back();
|
||||||
@@ -446,8 +447,8 @@ cmComputeLinkDepends::AllocateLinkEntry(cmLinkItem const& item)
|
|||||||
return lei;
|
return lei;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, bool> cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item,
|
std::pair<size_t, bool> cmComputeLinkDepends::AddLinkEntry(
|
||||||
int groupIndex)
|
cmLinkItem const& item, size_t groupIndex)
|
||||||
{
|
{
|
||||||
// Allocate a spot for the item entry.
|
// Allocate a spot for the item entry.
|
||||||
auto lei = this->AllocateLinkEntry(item);
|
auto lei = this->AllocateLinkEntry(item);
|
||||||
@@ -459,7 +460,7 @@ std::pair<int, bool> cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the item entry.
|
// Initialize the item entry.
|
||||||
int index = lei.first->second;
|
size_t index = lei.first->second;
|
||||||
LinkEntry& entry = this->EntryList[index];
|
LinkEntry& entry = this->EntryList[index];
|
||||||
entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
|
entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
|
||||||
entry.Target = item.Target;
|
entry.Target = item.Target;
|
||||||
@@ -506,7 +507,7 @@ void cmComputeLinkDepends::AddLinkObject(cmLinkItem const& item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the item entry.
|
// Initialize the item entry.
|
||||||
int index = lei.first->second;
|
size_t index = lei.first->second;
|
||||||
LinkEntry& entry = this->EntryList[index];
|
LinkEntry& entry = this->EntryList[index];
|
||||||
entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
|
entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
|
||||||
entry.Kind = LinkEntry::Object;
|
entry.Kind = LinkEntry::Object;
|
||||||
@@ -518,7 +519,7 @@ void cmComputeLinkDepends::AddLinkObject(cmLinkItem const& item)
|
|||||||
void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe)
|
void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe)
|
||||||
{
|
{
|
||||||
// Get this entry representation.
|
// Get this entry representation.
|
||||||
int depender_index =
|
size_t depender_index =
|
||||||
qe.GroupIndex == cmComputeComponentGraph::INVALID_COMPONENT
|
qe.GroupIndex == cmComputeComponentGraph::INVALID_COMPONENT
|
||||||
? qe.Index
|
? qe.Index
|
||||||
: qe.GroupIndex;
|
: qe.GroupIndex;
|
||||||
@@ -559,7 +560,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeLinkDepends::FollowSharedDeps(int depender_index,
|
void cmComputeLinkDepends::FollowSharedDeps(size_t depender_index,
|
||||||
cmLinkInterface const* iface,
|
cmLinkInterface const* iface,
|
||||||
bool follow_interface)
|
bool follow_interface)
|
||||||
{
|
{
|
||||||
@@ -573,7 +574,7 @@ void cmComputeLinkDepends::FollowSharedDeps(int depender_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeLinkDepends::QueueSharedDependencies(
|
void cmComputeLinkDepends::QueueSharedDependencies(
|
||||||
int depender_index, std::vector<cmLinkItem> const& deps)
|
size_t depender_index, std::vector<cmLinkItem> const& deps)
|
||||||
{
|
{
|
||||||
for (cmLinkItem const& li : deps) {
|
for (cmLinkItem const& li : deps) {
|
||||||
SharedDepEntry qe;
|
SharedDepEntry qe;
|
||||||
@@ -587,7 +588,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
|
|||||||
{
|
{
|
||||||
// Allocate a spot for the item entry.
|
// Allocate a spot for the item entry.
|
||||||
auto lei = this->AllocateLinkEntry(dep.Item);
|
auto lei = this->AllocateLinkEntry(dep.Item);
|
||||||
int index = lei.first->second;
|
size_t index = lei.first->second;
|
||||||
|
|
||||||
// Check if the target does not already has an entry.
|
// Check if the target does not already has an entry.
|
||||||
if (lei.second) {
|
if (lei.second) {
|
||||||
@@ -620,7 +621,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
|
void cmComputeLinkDepends::AddVarLinkEntries(size_t depender_index,
|
||||||
const char* value)
|
const char* value)
|
||||||
{
|
{
|
||||||
// This is called to add the dependencies named by
|
// This is called to add the dependencies named by
|
||||||
@@ -699,17 +700,18 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void cmComputeLinkDepends::AddLinkEntries(int depender_index,
|
void cmComputeLinkDepends::AddLinkEntries(size_t depender_index,
|
||||||
std::vector<T> const& libs)
|
std::vector<T> const& libs)
|
||||||
{
|
{
|
||||||
// Track inferred dependency sets implied by this list.
|
// Track inferred dependency sets implied by this list.
|
||||||
std::map<int, DependSet> dependSets;
|
std::map<size_t, DependSet> dependSets;
|
||||||
std::string feature = LinkEntry::DEFAULT;
|
std::string feature = LinkEntry::DEFAULT;
|
||||||
|
|
||||||
bool inGroup = false;
|
bool inGroup = false;
|
||||||
std::pair<int, bool> groupIndex{ cmComputeComponentGraph::INVALID_COMPONENT,
|
std::pair<size_t, bool> groupIndex{
|
||||||
false };
|
cmComputeComponentGraph::INVALID_COMPONENT, false
|
||||||
std::vector<int> groupItems;
|
};
|
||||||
|
std::vector<size_t> groupItems;
|
||||||
|
|
||||||
// Loop over the libraries linked directly by the depender.
|
// Loop over the libraries linked directly by the depender.
|
||||||
for (T const& l : libs) {
|
for (T const& l : libs) {
|
||||||
@@ -768,7 +770,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dependee_index;
|
size_t dependee_index;
|
||||||
|
|
||||||
if (cmHasPrefix(item.AsStr(), LG_END) && cmHasSuffix(item.AsStr(), '>')) {
|
if (cmHasPrefix(item.AsStr(), LG_END) && cmHasSuffix(item.AsStr(), '>')) {
|
||||||
dependee_index = groupIndex.first;
|
dependee_index = groupIndex.first;
|
||||||
@@ -902,7 +904,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
|
|||||||
// store item index for dependencies handling
|
// store item index for dependencies handling
|
||||||
groupItems.push_back(dependee_index);
|
groupItems.push_back(dependee_index);
|
||||||
} else {
|
} else {
|
||||||
std::vector<int> indexes;
|
std::vector<size_t> indexes;
|
||||||
bool entryHandled = false;
|
bool entryHandled = false;
|
||||||
// search any occurrence of the library in already defined groups
|
// search any occurrence of the library in already defined groups
|
||||||
for (const auto& group : this->GroupItems) {
|
for (const auto& group : this->GroupItems) {
|
||||||
@@ -964,7 +966,7 @@ void cmComputeLinkDepends::AddLinkObjects(std::vector<cmLinkItem> const& objs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmLinkItem cmComputeLinkDepends::ResolveLinkItem(int depender_index,
|
cmLinkItem cmComputeLinkDepends::ResolveLinkItem(size_t depender_index,
|
||||||
const std::string& name)
|
const std::string& name)
|
||||||
{
|
{
|
||||||
// Look for a target in the scope of the depender.
|
// Look for a target in the scope of the depender.
|
||||||
@@ -983,7 +985,7 @@ void cmComputeLinkDepends::InferDependencies()
|
|||||||
// The inferred dependency sets for each item list the possible
|
// The inferred dependency sets for each item list the possible
|
||||||
// dependencies. The intersection of the sets for one item form its
|
// dependencies. The intersection of the sets for one item form its
|
||||||
// inferred dependencies.
|
// inferred dependencies.
|
||||||
for (unsigned int depender_index = 0;
|
for (size_t depender_index = 0;
|
||||||
depender_index < this->InferredDependSets.size(); ++depender_index) {
|
depender_index < this->InferredDependSets.size(); ++depender_index) {
|
||||||
// Skip items for which dependencies do not need to be inferred or
|
// Skip items for which dependencies do not need to be inferred or
|
||||||
// for which the inferred dependency sets are empty.
|
// for which the inferred dependency sets are empty.
|
||||||
@@ -1020,7 +1022,7 @@ void cmComputeLinkDepends::UpdateGroupDependencies()
|
|||||||
// over raw items by the group it belongs to, if any.
|
// over raw items by the group it belongs to, if any.
|
||||||
for (auto& edgeList : this->EntryConstraintGraph) {
|
for (auto& edgeList : this->EntryConstraintGraph) {
|
||||||
for (auto& edge : edgeList) {
|
for (auto& edge : edgeList) {
|
||||||
int index = edge;
|
size_t index = edge;
|
||||||
if (this->EntryList[index].Kind == LinkEntry::Group ||
|
if (this->EntryList[index].Kind == LinkEntry::Group ||
|
||||||
this->EntryList[index].Kind == LinkEntry::Flag ||
|
this->EntryList[index].Kind == LinkEntry::Flag ||
|
||||||
this->EntryList[index].Kind == LinkEntry::Object) {
|
this->EntryList[index].Kind == LinkEntry::Object) {
|
||||||
@@ -1056,8 +1058,8 @@ void cmComputeLinkDepends::CleanConstraintGraph()
|
|||||||
bool cmComputeLinkDepends::CheckCircularDependencies() const
|
bool cmComputeLinkDepends::CheckCircularDependencies() const
|
||||||
{
|
{
|
||||||
std::vector<NodeList> const& components = this->CCG->GetComponents();
|
std::vector<NodeList> const& components = this->CCG->GetComponents();
|
||||||
int nc = static_cast<int>(components.size());
|
size_t nc = components.size();
|
||||||
for (int c = 0; c < nc; ++c) {
|
for (size_t c = 0; c < nc; ++c) {
|
||||||
// Get the current component.
|
// Get the current component.
|
||||||
NodeList const& nl = components[c];
|
NodeList const& nl = components[c];
|
||||||
|
|
||||||
@@ -1068,7 +1070,7 @@ bool cmComputeLinkDepends::CheckCircularDependencies() const
|
|||||||
|
|
||||||
// no group must be evolved
|
// no group must be evolved
|
||||||
bool cycleDetected = false;
|
bool cycleDetected = false;
|
||||||
for (int ni : nl) {
|
for (size_t ni : nl) {
|
||||||
if (this->EntryList[ni].Kind == LinkEntry::Group) {
|
if (this->EntryList[ni].Kind == LinkEntry::Group) {
|
||||||
cycleDetected = true;
|
cycleDetected = true;
|
||||||
break;
|
break;
|
||||||
@@ -1096,8 +1098,8 @@ bool cmComputeLinkDepends::CheckCircularDependencies() const
|
|||||||
<< this->Target->GetName()
|
<< this->Target->GetName()
|
||||||
<< "\", contains the following strongly connected component "
|
<< "\", contains the following strongly connected component "
|
||||||
"(cycle):\n";
|
"(cycle):\n";
|
||||||
std::vector<int> const& cmap = this->CCG->GetComponentMap();
|
std::vector<size_t> const& cmap = this->CCG->GetComponentMap();
|
||||||
for (int i : nl) {
|
for (size_t i : nl) {
|
||||||
// Get the depender.
|
// Get the depender.
|
||||||
LinkEntry const& depender = this->EntryList[i];
|
LinkEntry const& depender = this->EntryList[i];
|
||||||
|
|
||||||
@@ -1107,7 +1109,7 @@ bool cmComputeLinkDepends::CheckCircularDependencies() const
|
|||||||
// List its dependencies that are inside the component.
|
// List its dependencies that are inside the component.
|
||||||
EdgeList const& el = this->EntryConstraintGraph[i];
|
EdgeList const& el = this->EntryConstraintGraph[i];
|
||||||
for (cmGraphEdge const& ni : el) {
|
for (cmGraphEdge const& ni : el) {
|
||||||
int j = ni;
|
size_t j = ni;
|
||||||
if (cmap[j] == c) {
|
if (cmap[j] == c) {
|
||||||
LinkEntry const& dependee = this->EntryList[j];
|
LinkEntry const& dependee = this->EntryList[j];
|
||||||
e << " depends on " << formatItem(dependee) << "\n";
|
e << " depends on " << formatItem(dependee) << "\n";
|
||||||
@@ -1127,7 +1129,7 @@ void cmComputeLinkDepends::DisplayConstraintGraph()
|
|||||||
{
|
{
|
||||||
// Display the graph nodes and their edges.
|
// Display the graph nodes and their edges.
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
for (unsigned int i = 0; i < this->EntryConstraintGraph.size(); ++i) {
|
for (size_t i = 0; i < this->EntryConstraintGraph.size(); ++i) {
|
||||||
EdgeList const& nl = this->EntryConstraintGraph[i];
|
EdgeList const& nl = this->EntryConstraintGraph[i];
|
||||||
e << "item " << i << " is [" << this->EntryList[i].Item << "]\n";
|
e << "item " << i << " is [" << this->EntryList[i].Item << "]\n";
|
||||||
e << cmWrap(" item ", nl, " must follow it", "\n") << "\n";
|
e << cmWrap(" item ", nl, " must follow it", "\n") << "\n";
|
||||||
@@ -1141,13 +1143,14 @@ void cmComputeLinkDepends::OrderLinkEntries()
|
|||||||
// from every entry to compute a topological order for the
|
// from every entry to compute a topological order for the
|
||||||
// components.
|
// components.
|
||||||
Graph const& cgraph = this->CCG->GetComponentGraph();
|
Graph const& cgraph = this->CCG->GetComponentGraph();
|
||||||
int n = static_cast<int>(cgraph.size());
|
size_t n = cgraph.size();
|
||||||
this->ComponentVisited.resize(cgraph.size(), 0);
|
this->ComponentVisited.resize(cgraph.size(), 0);
|
||||||
this->ComponentOrder.resize(cgraph.size(), n);
|
this->ComponentOrder.resize(cgraph.size(), n);
|
||||||
this->ComponentOrderId = n;
|
this->ComponentOrderId = n;
|
||||||
// Run in reverse order so the topological order will preserve the
|
// Run in reverse order so the topological order will preserve the
|
||||||
// original order where there are no constraints.
|
// original order where there are no constraints.
|
||||||
for (int c = n - 1; c != cmComputeComponentGraph::INVALID_COMPONENT; --c) {
|
for (size_t c = n - 1; c != cmComputeComponentGraph::INVALID_COMPONENT;
|
||||||
|
--c) {
|
||||||
this->VisitComponent(c);
|
this->VisitComponent(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1157,7 +1160,7 @@ void cmComputeLinkDepends::OrderLinkEntries()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start with the original link line.
|
// Start with the original link line.
|
||||||
for (int originalEntry : this->OriginalEntries) {
|
for (size_t originalEntry : this->OriginalEntries) {
|
||||||
this->VisitEntry(originalEntry);
|
this->VisitEntry(originalEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1168,7 +1171,7 @@ void cmComputeLinkDepends::OrderLinkEntries()
|
|||||||
// logic will update the pending components accordingly. Since
|
// logic will update the pending components accordingly. Since
|
||||||
// the pending components are kept in topological order this will
|
// the pending components are kept in topological order this will
|
||||||
// not repeat one.
|
// not repeat one.
|
||||||
int e = *this->PendingComponents.begin()->second.Entries.begin();
|
size_t e = *this->PendingComponents.begin()->second.Entries.begin();
|
||||||
this->VisitEntry(e);
|
this->VisitEntry(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1177,24 +1180,24 @@ void cmComputeLinkDepends::DisplayComponents()
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "The strongly connected components are:\n");
|
fprintf(stderr, "The strongly connected components are:\n");
|
||||||
std::vector<NodeList> const& components = this->CCG->GetComponents();
|
std::vector<NodeList> const& components = this->CCG->GetComponents();
|
||||||
for (unsigned int c = 0; c < components.size(); ++c) {
|
for (size_t c = 0; c < components.size(); ++c) {
|
||||||
fprintf(stderr, "Component (%u):\n", c);
|
fprintf(stderr, "Component (%zu):\n", c);
|
||||||
NodeList const& nl = components[c];
|
NodeList const& nl = components[c];
|
||||||
for (int i : nl) {
|
for (size_t i : nl) {
|
||||||
fprintf(stderr, " item %d [%s]\n", i,
|
fprintf(stderr, " item %zu [%s]\n", i,
|
||||||
this->EntryList[i].Item.Value.c_str());
|
this->EntryList[i].Item.Value.c_str());
|
||||||
}
|
}
|
||||||
EdgeList const& ol = this->CCG->GetComponentGraphEdges(c);
|
EdgeList const& ol = this->CCG->GetComponentGraphEdges(c);
|
||||||
for (cmGraphEdge const& oi : ol) {
|
for (cmGraphEdge const& oi : ol) {
|
||||||
int i = oi;
|
size_t i = oi;
|
||||||
fprintf(stderr, " followed by Component (%d)\n", i);
|
fprintf(stderr, " followed by Component (%zu)\n", i);
|
||||||
}
|
}
|
||||||
fprintf(stderr, " topo order index %d\n", this->ComponentOrder[c]);
|
fprintf(stderr, " topo order index %zu\n", this->ComponentOrder[c]);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeLinkDepends::VisitComponent(unsigned int c)
|
void cmComputeLinkDepends::VisitComponent(size_t c)
|
||||||
{
|
{
|
||||||
// Check if the node has already been visited.
|
// Check if the node has already been visited.
|
||||||
if (this->ComponentVisited[c]) {
|
if (this->ComponentVisited[c]) {
|
||||||
@@ -1216,14 +1219,14 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c)
|
|||||||
this->ComponentOrder[c] = --this->ComponentOrderId;
|
this->ComponentOrder[c] = --this->ComponentOrderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeLinkDepends::VisitEntry(int index)
|
void cmComputeLinkDepends::VisitEntry(size_t index)
|
||||||
{
|
{
|
||||||
// Include this entry on the link line.
|
// Include this entry on the link line.
|
||||||
this->FinalLinkOrder.push_back(index);
|
this->FinalLinkOrder.push_back(index);
|
||||||
|
|
||||||
// This entry has now been seen. Update its component.
|
// This entry has now been seen. Update its component.
|
||||||
bool completed = false;
|
bool completed = false;
|
||||||
int component = this->CCG->GetComponentMap()[index];
|
size_t component = this->CCG->GetComponentMap()[index];
|
||||||
auto mi = this->PendingComponents.find(this->ComponentOrder[component]);
|
auto mi = this->PendingComponents.find(this->ComponentOrder[component]);
|
||||||
if (mi != this->PendingComponents.end()) {
|
if (mi != this->PendingComponents.end()) {
|
||||||
// The entry is in an already pending component.
|
// The entry is in an already pending component.
|
||||||
@@ -1274,7 +1277,7 @@ void cmComputeLinkDepends::VisitEntry(int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmComputeLinkDepends::PendingComponent&
|
cmComputeLinkDepends::PendingComponent&
|
||||||
cmComputeLinkDepends::MakePendingComponent(unsigned int component)
|
cmComputeLinkDepends::MakePendingComponent(size_t component)
|
||||||
{
|
{
|
||||||
// Create an entry (in topological order) for the component.
|
// Create an entry (in topological order) for the component.
|
||||||
PendingComponent& pc =
|
PendingComponent& pc =
|
||||||
@@ -1307,10 +1310,10 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
|
|||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
|
size_t cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
|
||||||
{
|
{
|
||||||
unsigned int count = 2;
|
size_t count = 2;
|
||||||
for (int ni : nl) {
|
for (size_t ni : nl) {
|
||||||
if (cmGeneratorTarget const* target = this->EntryList[ni].Target) {
|
if (cmGeneratorTarget const* target = this->EntryList[ni].Target) {
|
||||||
if (cmLinkInterface const* iface =
|
if (cmLinkInterface const* iface =
|
||||||
target->GetLinkInterface(this->Config, this->Target)) {
|
target->GetLinkInterface(this->Config, this->Target)) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
@@ -12,12 +13,12 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "cmComputeComponentGraph.h"
|
||||||
#include "cmGraphAdjacencyList.h"
|
#include "cmGraphAdjacencyList.h"
|
||||||
#include "cmLinkItem.h"
|
#include "cmLinkItem.h"
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
#include "cmTargetLinkLibraryType.h"
|
#include "cmTargetLinkLibraryType.h"
|
||||||
|
|
||||||
class cmComputeComponentGraph;
|
|
||||||
class cmGeneratorTarget;
|
class cmGeneratorTarget;
|
||||||
class cmGlobalGenerator;
|
class cmGlobalGenerator;
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
@@ -91,31 +92,31 @@ private:
|
|||||||
std::string const& GetCurrentFeature(
|
std::string const& GetCurrentFeature(
|
||||||
std::string const& item, std::string const& defaultFeature) const;
|
std::string const& item, std::string const& defaultFeature) const;
|
||||||
|
|
||||||
std::pair<std::map<cmLinkItem, int>::iterator, bool> AllocateLinkEntry(
|
std::pair<std::map<cmLinkItem, size_t>::iterator, bool> AllocateLinkEntry(
|
||||||
cmLinkItem const& item);
|
cmLinkItem const& item);
|
||||||
std::pair<int, bool> AddLinkEntry(
|
std::pair<size_t, bool> AddLinkEntry(
|
||||||
cmLinkItem const& item,
|
cmLinkItem const& item,
|
||||||
int groupIndex = cmComputeComponentGraph::INVALID_COMPONENT);
|
size_t groupIndex = cmComputeComponentGraph::INVALID_COMPONENT);
|
||||||
void AddLinkObject(cmLinkItem const& item);
|
void AddLinkObject(cmLinkItem const& item);
|
||||||
void AddVarLinkEntries(int depender_index, const char* value);
|
void AddVarLinkEntries(size_t depender_index, const char* value);
|
||||||
void AddDirectLinkEntries();
|
void AddDirectLinkEntries();
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddLinkEntries(int depender_index, std::vector<T> const& libs);
|
void AddLinkEntries(size_t depender_index, std::vector<T> const& libs);
|
||||||
void AddLinkObjects(std::vector<cmLinkItem> const& objs);
|
void AddLinkObjects(std::vector<cmLinkItem> const& objs);
|
||||||
cmLinkItem ResolveLinkItem(int depender_index, const std::string& name);
|
cmLinkItem ResolveLinkItem(size_t depender_index, const std::string& name);
|
||||||
|
|
||||||
// One entry for each unique item.
|
// One entry for each unique item.
|
||||||
std::vector<LinkEntry> EntryList;
|
std::vector<LinkEntry> EntryList;
|
||||||
std::map<cmLinkItem, int> LinkEntryIndex;
|
std::map<cmLinkItem, size_t> LinkEntryIndex;
|
||||||
|
|
||||||
// map storing, for each group, the list of items
|
// map storing, for each group, the list of items
|
||||||
std::map<int, std::vector<int>> GroupItems;
|
std::map<size_t, std::vector<size_t>> GroupItems;
|
||||||
|
|
||||||
// BFS of initial dependencies.
|
// BFS of initial dependencies.
|
||||||
struct BFSEntry
|
struct BFSEntry
|
||||||
{
|
{
|
||||||
int Index;
|
size_t Index;
|
||||||
int GroupIndex;
|
size_t GroupIndex;
|
||||||
const char* LibDepends;
|
const char* LibDepends;
|
||||||
};
|
};
|
||||||
std::queue<BFSEntry> BFSQueue;
|
std::queue<BFSEntry> BFSQueue;
|
||||||
@@ -127,18 +128,18 @@ private:
|
|||||||
struct SharedDepEntry
|
struct SharedDepEntry
|
||||||
{
|
{
|
||||||
cmLinkItem Item;
|
cmLinkItem Item;
|
||||||
int DependerIndex;
|
size_t DependerIndex;
|
||||||
};
|
};
|
||||||
std::queue<SharedDepEntry> SharedDepQueue;
|
std::queue<SharedDepEntry> SharedDepQueue;
|
||||||
std::set<int> SharedDepFollowed;
|
std::set<size_t> SharedDepFollowed;
|
||||||
void FollowSharedDeps(int depender_index, cmLinkInterface const* iface,
|
void FollowSharedDeps(size_t depender_index, cmLinkInterface const* iface,
|
||||||
bool follow_interface = false);
|
bool follow_interface = false);
|
||||||
void QueueSharedDependencies(int depender_index,
|
void QueueSharedDependencies(size_t depender_index,
|
||||||
std::vector<cmLinkItem> const& deps);
|
std::vector<cmLinkItem> const& deps);
|
||||||
void HandleSharedDependency(SharedDepEntry const& dep);
|
void HandleSharedDependency(SharedDepEntry const& dep);
|
||||||
|
|
||||||
// Dependency inferral for each link item.
|
// Dependency inferral for each link item.
|
||||||
struct DependSet : public std::set<int>
|
struct DependSet : public std::set<size_t>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
struct DependSetList : public std::vector<DependSet>
|
struct DependSetList : public std::vector<DependSet>
|
||||||
@@ -163,41 +164,41 @@ private:
|
|||||||
// Ordering algorithm.
|
// Ordering algorithm.
|
||||||
void OrderLinkEntries();
|
void OrderLinkEntries();
|
||||||
std::vector<char> ComponentVisited;
|
std::vector<char> ComponentVisited;
|
||||||
std::vector<int> ComponentOrder;
|
std::vector<size_t> ComponentOrder;
|
||||||
|
|
||||||
struct PendingComponent
|
struct PendingComponent
|
||||||
{
|
{
|
||||||
// The real component id. Needed because the map is indexed by
|
// The real component id. Needed because the map is indexed by
|
||||||
// component topological index.
|
// component topological index.
|
||||||
int Id;
|
size_t Id;
|
||||||
|
|
||||||
// The number of times the component needs to be seen. This is
|
// The number of times the component needs to be seen. This is
|
||||||
// always 1 for trivial components and is initially 2 for
|
// always 1 for trivial components and is initially 2 for
|
||||||
// non-trivial components.
|
// non-trivial components.
|
||||||
int Count;
|
size_t Count;
|
||||||
|
|
||||||
// The entries yet to be seen to complete the component.
|
// The entries yet to be seen to complete the component.
|
||||||
std::set<int> Entries;
|
std::set<size_t> Entries;
|
||||||
};
|
};
|
||||||
std::map<int, PendingComponent> PendingComponents;
|
std::map<size_t, PendingComponent> PendingComponents;
|
||||||
std::unique_ptr<cmComputeComponentGraph> CCG;
|
std::unique_ptr<cmComputeComponentGraph> CCG;
|
||||||
std::vector<int> FinalLinkOrder;
|
std::vector<size_t> FinalLinkOrder;
|
||||||
void DisplayComponents();
|
void DisplayComponents();
|
||||||
void VisitComponent(unsigned int c);
|
void VisitComponent(size_t c);
|
||||||
void VisitEntry(int index);
|
void VisitEntry(size_t index);
|
||||||
PendingComponent& MakePendingComponent(unsigned int component);
|
PendingComponent& MakePendingComponent(size_t component);
|
||||||
int ComputeComponentCount(NodeList const& nl);
|
size_t ComputeComponentCount(NodeList const& nl);
|
||||||
void DisplayFinalEntries();
|
void DisplayFinalEntries();
|
||||||
|
|
||||||
// Record of the original link line.
|
// Record of the original link line.
|
||||||
std::vector<int> OriginalEntries;
|
std::vector<size_t> OriginalEntries;
|
||||||
std::set<cmGeneratorTarget const*> OldWrongConfigItems;
|
std::set<cmGeneratorTarget const*> OldWrongConfigItems;
|
||||||
void CheckWrongConfigItem(cmLinkItem const& item);
|
void CheckWrongConfigItem(cmLinkItem const& item);
|
||||||
|
|
||||||
// Record of explicitly linked object files.
|
// Record of explicitly linked object files.
|
||||||
std::vector<int> ObjectEntries;
|
std::vector<size_t> ObjectEntries;
|
||||||
|
|
||||||
int ComponentOrderId;
|
size_t ComponentOrderId;
|
||||||
cmTargetLinkLibraryType LinkType;
|
cmTargetLinkLibraryType LinkType;
|
||||||
bool HasConfig;
|
bool HasConfig;
|
||||||
bool DebugMode;
|
bool DebugMode;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "cmComputeTargetDepends.h"
|
#include "cmComputeTargetDepends.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -159,7 +160,7 @@ void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
|
|||||||
// this point.
|
// this point.
|
||||||
auto tii = this->TargetIndex.find(t);
|
auto tii = this->TargetIndex.find(t);
|
||||||
assert(tii != this->TargetIndex.end());
|
assert(tii != this->TargetIndex.end());
|
||||||
int i = tii->second;
|
size_t i = tii->second;
|
||||||
|
|
||||||
// Get its final dependencies.
|
// Get its final dependencies.
|
||||||
EdgeList const& nl = this->FinalGraph[i];
|
EdgeList const& nl = this->FinalGraph[i];
|
||||||
@@ -178,7 +179,7 @@ void cmComputeTargetDepends::CollectTargets()
|
|||||||
auto const& lgens = this->GlobalGenerator->GetLocalGenerators();
|
auto const& lgens = this->GlobalGenerator->GetLocalGenerators();
|
||||||
for (const auto& lgen : lgens) {
|
for (const auto& lgen : lgens) {
|
||||||
for (const auto& ti : lgen->GetGeneratorTargets()) {
|
for (const auto& ti : lgen->GetGeneratorTargets()) {
|
||||||
int index = static_cast<int>(this->Targets.size());
|
size_t index = this->Targets.size();
|
||||||
this->TargetIndex[ti.get()] = index;
|
this->TargetIndex[ti.get()] = index;
|
||||||
this->Targets.push_back(ti.get());
|
this->Targets.push_back(ti.get());
|
||||||
}
|
}
|
||||||
@@ -191,12 +192,12 @@ void cmComputeTargetDepends::CollectDepends()
|
|||||||
this->InitialGraph.resize(this->Targets.size());
|
this->InitialGraph.resize(this->Targets.size());
|
||||||
|
|
||||||
// Compute each dependency list.
|
// Compute each dependency list.
|
||||||
for (unsigned int i = 0; i < this->Targets.size(); ++i) {
|
for (size_t i = 0; i < this->Targets.size(); ++i) {
|
||||||
this->CollectTargetDepends(i);
|
this->CollectTargetDepends(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
|
void cmComputeTargetDepends::CollectTargetDepends(size_t depender_index)
|
||||||
{
|
{
|
||||||
// Get the depender.
|
// Get the depender.
|
||||||
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
||||||
@@ -261,7 +262,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::AddInterfaceDepends(
|
void cmComputeTargetDepends::AddInterfaceDepends(
|
||||||
int depender_index, const cmGeneratorTarget* dependee,
|
size_t depender_index, const cmGeneratorTarget* dependee,
|
||||||
cmListFileBacktrace const& dependee_backtrace, const std::string& config,
|
cmListFileBacktrace const& dependee_backtrace, const std::string& config,
|
||||||
std::set<cmLinkItem>& emitted)
|
std::set<cmLinkItem>& emitted)
|
||||||
{
|
{
|
||||||
@@ -290,7 +291,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::AddInterfaceDepends(
|
void cmComputeTargetDepends::AddInterfaceDepends(
|
||||||
int depender_index, cmLinkItem const& dependee_name,
|
size_t depender_index, cmLinkItem const& dependee_name,
|
||||||
const std::string& config, std::set<cmLinkItem>& emitted)
|
const std::string& config, std::set<cmLinkItem>& emitted)
|
||||||
{
|
{
|
||||||
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
||||||
@@ -312,7 +313,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::AddObjectDepends(int depender_index,
|
void cmComputeTargetDepends::AddObjectDepends(size_t depender_index,
|
||||||
cmSourceFile const* o,
|
cmSourceFile const* o,
|
||||||
std::set<cmLinkItem>& emitted)
|
std::set<cmLinkItem>& emitted)
|
||||||
{
|
{
|
||||||
@@ -340,7 +341,7 @@ void cmComputeTargetDepends::AddObjectDepends(int depender_index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::AddTargetDepend(int depender_index,
|
void cmComputeTargetDepends::AddTargetDepend(size_t depender_index,
|
||||||
cmLinkItem const& dependee_name,
|
cmLinkItem const& dependee_name,
|
||||||
bool linking, bool cross)
|
bool linking, bool cross)
|
||||||
{
|
{
|
||||||
@@ -394,7 +395,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::AddTargetDepend(
|
void cmComputeTargetDepends::AddTargetDepend(
|
||||||
int depender_index, cmGeneratorTarget const* dependee,
|
size_t depender_index, cmGeneratorTarget const* dependee,
|
||||||
cmListFileBacktrace const& dependee_backtrace, bool linking, bool cross)
|
cmListFileBacktrace const& dependee_backtrace, bool linking, bool cross)
|
||||||
{
|
{
|
||||||
if (!dependee->IsInBuildSystem()) {
|
if (!dependee->IsInBuildSystem()) {
|
||||||
@@ -412,7 +413,7 @@ void cmComputeTargetDepends::AddTargetDepend(
|
|||||||
// this point.
|
// this point.
|
||||||
auto tii = this->TargetIndex.find(dependee);
|
auto tii = this->TargetIndex.find(dependee);
|
||||||
assert(tii != this->TargetIndex.end());
|
assert(tii != this->TargetIndex.end());
|
||||||
int dependee_index = tii->second;
|
size_t dependee_index = tii->second;
|
||||||
|
|
||||||
// Add this entry to the dependency graph.
|
// Add this entry to the dependency graph.
|
||||||
this->InitialGraph[depender_index].emplace_back(dependee_index, !linking,
|
this->InitialGraph[depender_index].emplace_back(dependee_index, !linking,
|
||||||
@@ -425,15 +426,15 @@ void cmComputeTargetDepends::CollectSideEffects()
|
|||||||
this->SideEffects.resize(0);
|
this->SideEffects.resize(0);
|
||||||
this->SideEffects.resize(this->InitialGraph.size());
|
this->SideEffects.resize(this->InitialGraph.size());
|
||||||
|
|
||||||
int n = static_cast<int>(this->InitialGraph.size());
|
size_t n = this->InitialGraph.size();
|
||||||
std::set<int> visited;
|
std::set<size_t> visited;
|
||||||
for (int i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
this->CollectSideEffectsForTarget(visited, i);
|
this->CollectSideEffectsForTarget(visited, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::CollectSideEffectsForTarget(
|
void cmComputeTargetDepends::CollectSideEffectsForTarget(
|
||||||
std::set<int>& visited, int depender_index)
|
std::set<size_t>& visited, size_t depender_index)
|
||||||
{
|
{
|
||||||
if (!visited.count(depender_index)) {
|
if (!visited.count(depender_index)) {
|
||||||
auto& se = this->SideEffects[depender_index];
|
auto& se = this->SideEffects[depender_index];
|
||||||
@@ -461,8 +462,8 @@ void cmComputeTargetDepends::ComputeIntermediateGraph()
|
|||||||
this->IntermediateGraph.resize(0);
|
this->IntermediateGraph.resize(0);
|
||||||
this->IntermediateGraph.resize(this->InitialGraph.size());
|
this->IntermediateGraph.resize(this->InitialGraph.size());
|
||||||
|
|
||||||
int n = static_cast<int>(this->InitialGraph.size());
|
size_t n = this->InitialGraph.size();
|
||||||
for (int i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
auto const& initialEdges = this->InitialGraph[i];
|
auto const& initialEdges = this->InitialGraph[i];
|
||||||
auto& intermediateEdges = this->IntermediateGraph[i];
|
auto& intermediateEdges = this->IntermediateGraph[i];
|
||||||
cmGeneratorTarget const* gt = this->Targets[i];
|
cmGeneratorTarget const* gt = this->Targets[i];
|
||||||
@@ -488,7 +489,7 @@ void cmComputeTargetDepends::OptimizeLinkDependencies(
|
|||||||
cmGeneratorTarget const* gt, cmGraphEdgeList& outputEdges,
|
cmGeneratorTarget const* gt, cmGraphEdgeList& outputEdges,
|
||||||
cmGraphEdgeList const& inputEdges)
|
cmGraphEdgeList const& inputEdges)
|
||||||
{
|
{
|
||||||
std::set<int> emitted;
|
std::set<size_t> emitted;
|
||||||
for (auto const& edge : inputEdges) {
|
for (auto const& edge : inputEdges) {
|
||||||
if (edge.IsStrong()) {
|
if (edge.IsStrong()) {
|
||||||
// Preserve strong edges
|
// Preserve strong edges
|
||||||
@@ -529,16 +530,16 @@ void cmComputeTargetDepends::DisplayGraph(Graph const& graph,
|
|||||||
const std::string& name)
|
const std::string& name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
|
fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
|
||||||
int n = static_cast<int>(graph.size());
|
size_t n = graph.size();
|
||||||
for (int depender_index = 0; depender_index < n; ++depender_index) {
|
for (size_t depender_index = 0; depender_index < n; ++depender_index) {
|
||||||
EdgeList const& nl = graph[depender_index];
|
EdgeList const& nl = graph[depender_index];
|
||||||
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
||||||
fprintf(stderr, "target %d is [%s]\n", depender_index,
|
fprintf(stderr, "target %zu is [%s]\n", depender_index,
|
||||||
depender->GetName().c_str());
|
depender->GetName().c_str());
|
||||||
for (cmGraphEdge const& ni : nl) {
|
for (cmGraphEdge const& ni : nl) {
|
||||||
int dependee_index = ni;
|
size_t dependee_index = ni;
|
||||||
cmGeneratorTarget const* dependee = this->Targets[dependee_index];
|
cmGeneratorTarget const* dependee = this->Targets[dependee_index];
|
||||||
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
|
fprintf(stderr, " depends on target %zu [%s] (%s)\n", dependee_index,
|
||||||
dependee->GetName().c_str(), ni.IsStrong() ? "strong" : "weak");
|
dependee->GetName().c_str(), ni.IsStrong() ? "strong" : "weak");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,16 +549,16 @@ void cmComputeTargetDepends::DisplayGraph(Graph const& graph,
|
|||||||
void cmComputeTargetDepends::DisplaySideEffects()
|
void cmComputeTargetDepends::DisplaySideEffects()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "The side effects are:\n");
|
fprintf(stderr, "The side effects are:\n");
|
||||||
int n = static_cast<int>(this->SideEffects.size());
|
size_t n = this->SideEffects.size();
|
||||||
for (int depender_index = 0; depender_index < n; ++depender_index) {
|
for (size_t depender_index = 0; depender_index < n; ++depender_index) {
|
||||||
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
cmGeneratorTarget const* depender = this->Targets[depender_index];
|
||||||
fprintf(stderr, "target %d is [%s]\n", depender_index,
|
fprintf(stderr, "target %zu is [%s]\n", depender_index,
|
||||||
depender->GetName().c_str());
|
depender->GetName().c_str());
|
||||||
if (!this->SideEffects[depender_index].CustomCommandSideEffects.empty()) {
|
if (!this->SideEffects[depender_index].CustomCommandSideEffects.empty()) {
|
||||||
fprintf(stderr, " custom commands\n");
|
fprintf(stderr, " custom commands\n");
|
||||||
for (auto const* gt :
|
for (auto const* gt :
|
||||||
this->SideEffects[depender_index].CustomCommandSideEffects) {
|
this->SideEffects[depender_index].CustomCommandSideEffects) {
|
||||||
fprintf(stderr, " from target %d [%s]\n", this->TargetIndex[gt],
|
fprintf(stderr, " from target %zu [%s]\n", this->TargetIndex[gt],
|
||||||
gt->GetName().c_str());
|
gt->GetName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,7 +566,7 @@ void cmComputeTargetDepends::DisplaySideEffects()
|
|||||||
this->SideEffects[depender_index].LanguageSideEffects) {
|
this->SideEffects[depender_index].LanguageSideEffects) {
|
||||||
fprintf(stderr, " language %s\n", it.first.c_str());
|
fprintf(stderr, " language %s\n", it.first.c_str());
|
||||||
for (auto const* gt : it.second) {
|
for (auto const* gt : it.second) {
|
||||||
fprintf(stderr, " from target %d [%s]\n", this->TargetIndex[gt],
|
fprintf(stderr, " from target %zu [%s]\n", this->TargetIndex[gt],
|
||||||
gt->GetName().c_str());
|
gt->GetName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -579,12 +580,12 @@ void cmComputeTargetDepends::DisplayComponents(
|
|||||||
fprintf(stderr, "The strongly connected components for the %s graph are:\n",
|
fprintf(stderr, "The strongly connected components for the %s graph are:\n",
|
||||||
name.c_str());
|
name.c_str());
|
||||||
std::vector<NodeList> const& components = ccg.GetComponents();
|
std::vector<NodeList> const& components = ccg.GetComponents();
|
||||||
int n = static_cast<int>(components.size());
|
size_t n = components.size();
|
||||||
for (int c = 0; c < n; ++c) {
|
for (size_t c = 0; c < n; ++c) {
|
||||||
NodeList const& nl = components[c];
|
NodeList const& nl = components[c];
|
||||||
fprintf(stderr, "Component (%d):\n", c);
|
fprintf(stderr, "Component (%zu):\n", c);
|
||||||
for (int i : nl) {
|
for (size_t i : nl) {
|
||||||
fprintf(stderr, " contains target %d [%s]\n", i,
|
fprintf(stderr, " contains target %zu [%s]\n", i,
|
||||||
this->Targets[i]->GetName().c_str());
|
this->Targets[i]->GetName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -597,8 +598,8 @@ bool cmComputeTargetDepends::CheckComponents(
|
|||||||
// All non-trivial components should consist only of static
|
// All non-trivial components should consist only of static
|
||||||
// libraries.
|
// libraries.
|
||||||
std::vector<NodeList> const& components = ccg.GetComponents();
|
std::vector<NodeList> const& components = ccg.GetComponents();
|
||||||
int nc = static_cast<int>(components.size());
|
size_t nc = components.size();
|
||||||
for (int c = 0; c < nc; ++c) {
|
for (size_t c = 0; c < nc; ++c) {
|
||||||
// Get the current component.
|
// Get the current component.
|
||||||
NodeList const& nl = components[c];
|
NodeList const& nl = components[c];
|
||||||
|
|
||||||
@@ -614,7 +615,7 @@ bool cmComputeTargetDepends::CheckComponents(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the component is all STATIC_LIBRARY targets.
|
// Make sure the component is all STATIC_LIBRARY targets.
|
||||||
for (int ni : nl) {
|
for (size_t ni : nl) {
|
||||||
if (this->Targets[ni]->GetType() != cmStateEnums::STATIC_LIBRARY) {
|
if (this->Targets[ni]->GetType() != cmStateEnums::STATIC_LIBRARY) {
|
||||||
this->ComplainAboutBadComponent(ccg, c);
|
this->ComplainAboutBadComponent(ccg, c);
|
||||||
return false;
|
return false;
|
||||||
@@ -625,16 +626,16 @@ bool cmComputeTargetDepends::CheckComponents(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmComputeTargetDepends::ComplainAboutBadComponent(
|
void cmComputeTargetDepends::ComplainAboutBadComponent(
|
||||||
cmComputeComponentGraph const& ccg, int c, bool strong)
|
cmComputeComponentGraph const& ccg, size_t c, bool strong)
|
||||||
{
|
{
|
||||||
// Construct the error message.
|
// Construct the error message.
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "The inter-target dependency graph contains the following "
|
e << "The inter-target dependency graph contains the following "
|
||||||
<< "strongly connected component (cycle):\n";
|
<< "strongly connected component (cycle):\n";
|
||||||
std::vector<NodeList> const& components = ccg.GetComponents();
|
std::vector<NodeList> const& components = ccg.GetComponents();
|
||||||
std::vector<int> const& cmap = ccg.GetComponentMap();
|
std::vector<size_t> const& cmap = ccg.GetComponentMap();
|
||||||
NodeList const& cl = components[c];
|
NodeList const& cl = components[c];
|
||||||
for (int i : cl) {
|
for (size_t i : cl) {
|
||||||
// Get the depender.
|
// Get the depender.
|
||||||
cmGeneratorTarget const* depender = this->Targets[i];
|
cmGeneratorTarget const* depender = this->Targets[i];
|
||||||
|
|
||||||
@@ -645,7 +646,7 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
|
|||||||
// List its dependencies that are inside the component.
|
// List its dependencies that are inside the component.
|
||||||
EdgeList const& nl = this->InitialGraph[i];
|
EdgeList const& nl = this->InitialGraph[i];
|
||||||
for (cmGraphEdge const& ni : nl) {
|
for (cmGraphEdge const& ni : nl) {
|
||||||
int j = ni;
|
size_t j = ni;
|
||||||
if (cmap[j] == c) {
|
if (cmap[j] == c) {
|
||||||
cmGeneratorTarget const* dependee = this->Targets[j];
|
cmGeneratorTarget const* dependee = this->Targets[j];
|
||||||
e << " depends on \"" << dependee->GetName() << "\""
|
e << " depends on \"" << dependee->GetName() << "\""
|
||||||
@@ -669,10 +670,10 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
|
|||||||
cmSystemTools::Error(e.str());
|
cmSystemTools::Error(e.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
|
bool cmComputeTargetDepends::IntraComponent(std::vector<size_t> const& cmap,
|
||||||
int c, int i, int* head,
|
size_t c, size_t i, size_t* head,
|
||||||
std::set<int>& emitted,
|
std::set<size_t>& emitted,
|
||||||
std::set<int>& visited)
|
std::set<size_t>& visited)
|
||||||
{
|
{
|
||||||
if (!visited.insert(i).second) {
|
if (!visited.insert(i).second) {
|
||||||
// Cycle in utility depends!
|
// Cycle in utility depends!
|
||||||
@@ -682,7 +683,7 @@ bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
|
|||||||
// Honor strong intra-component edges in the final order.
|
// Honor strong intra-component edges in the final order.
|
||||||
EdgeList const& el = this->InitialGraph[i];
|
EdgeList const& el = this->InitialGraph[i];
|
||||||
for (cmGraphEdge const& edge : el) {
|
for (cmGraphEdge const& edge : el) {
|
||||||
int j = edge;
|
size_t j = edge;
|
||||||
if (cmap[j] == c && edge.IsStrong()) {
|
if (cmap[j] == c && edge.IsStrong()) {
|
||||||
this->FinalGraph[i].emplace_back(j, true, edge.IsCross(),
|
this->FinalGraph[i].emplace_back(j, true, edge.IsCross(),
|
||||||
edge.GetBacktrace());
|
edge.GetBacktrace());
|
||||||
@@ -716,16 +717,16 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
|
|||||||
this->FinalGraph.resize(this->InitialGraph.size());
|
this->FinalGraph.resize(this->InitialGraph.size());
|
||||||
|
|
||||||
// Choose intra-component edges to linearize dependencies.
|
// Choose intra-component edges to linearize dependencies.
|
||||||
std::vector<int> const& cmap = ccg.GetComponentMap();
|
std::vector<size_t> const& cmap = ccg.GetComponentMap();
|
||||||
this->ComponentHead.resize(components.size());
|
this->ComponentHead.resize(components.size());
|
||||||
this->ComponentTail.resize(components.size());
|
this->ComponentTail.resize(components.size());
|
||||||
int nc = static_cast<int>(components.size());
|
size_t nc = components.size();
|
||||||
for (int c = 0; c < nc; ++c) {
|
for (size_t c = 0; c < nc; ++c) {
|
||||||
int head = cmComputeComponentGraph::INVALID_COMPONENT;
|
size_t head = cmComputeComponentGraph::INVALID_COMPONENT;
|
||||||
std::set<int> emitted;
|
std::set<size_t> emitted;
|
||||||
NodeList const& nl = components[c];
|
NodeList const& nl = components[c];
|
||||||
for (int ni : cmReverseRange(nl)) {
|
for (size_t ni : cmReverseRange(nl)) {
|
||||||
std::set<int> visited;
|
std::set<size_t> visited;
|
||||||
if (!this->IntraComponent(cmap, c, ni, &head, emitted, visited)) {
|
if (!this->IntraComponent(cmap, c, ni, &head, emitted, visited)) {
|
||||||
// Cycle in add_dependencies within component!
|
// Cycle in add_dependencies within component!
|
||||||
this->ComplainAboutBadComponent(ccg, c, true);
|
this->ComplainAboutBadComponent(ccg, c, true);
|
||||||
@@ -736,14 +737,14 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert inter-component edges to connect component tails to heads.
|
// Convert inter-component edges to connect component tails to heads.
|
||||||
int n = static_cast<int>(cgraph.size());
|
size_t n = cgraph.size();
|
||||||
for (int depender_component = 0; depender_component < n;
|
for (size_t depender_component = 0; depender_component < n;
|
||||||
++depender_component) {
|
++depender_component) {
|
||||||
int depender_component_tail = this->ComponentTail[depender_component];
|
size_t depender_component_tail = this->ComponentTail[depender_component];
|
||||||
EdgeList const& nl = cgraph[depender_component];
|
EdgeList const& nl = cgraph[depender_component];
|
||||||
for (cmGraphEdge const& ni : nl) {
|
for (cmGraphEdge const& ni : nl) {
|
||||||
int dependee_component = ni;
|
size_t dependee_component = ni;
|
||||||
int dependee_component_head = this->ComponentHead[dependee_component];
|
size_t dependee_component_head = this->ComponentHead[dependee_component];
|
||||||
this->FinalGraph[depender_component_tail].emplace_back(
|
this->FinalGraph[depender_component_tail].emplace_back(
|
||||||
dependee_component_head, ni.IsStrong(), ni.IsCross(),
|
dependee_component_head, ni.IsStrong(), ni.IsCross(),
|
||||||
ni.GetBacktrace());
|
ni.GetBacktrace());
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -51,28 +52,31 @@ private:
|
|||||||
|
|
||||||
void CollectTargets();
|
void CollectTargets();
|
||||||
void CollectDepends();
|
void CollectDepends();
|
||||||
void CollectTargetDepends(int depender_index);
|
void CollectTargetDepends(size_t depender_index);
|
||||||
void AddTargetDepend(int depender_index, cmLinkItem const& dependee_name,
|
void AddTargetDepend(size_t depender_index, cmLinkItem const& dependee_name,
|
||||||
bool linking, bool cross);
|
bool linking, bool cross);
|
||||||
void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
|
void AddTargetDepend(size_t depender_index,
|
||||||
|
cmGeneratorTarget const* dependee,
|
||||||
cmListFileBacktrace const& dependee_backtrace,
|
cmListFileBacktrace const& dependee_backtrace,
|
||||||
bool linking, bool cross);
|
bool linking, bool cross);
|
||||||
void CollectSideEffects();
|
void CollectSideEffects();
|
||||||
void CollectSideEffectsForTarget(std::set<int>& visited, int depender_index);
|
void CollectSideEffectsForTarget(std::set<size_t>& visited,
|
||||||
|
size_t depender_index);
|
||||||
void ComputeIntermediateGraph();
|
void ComputeIntermediateGraph();
|
||||||
void OptimizeLinkDependencies(cmGeneratorTarget const* gt,
|
void OptimizeLinkDependencies(cmGeneratorTarget const* gt,
|
||||||
cmGraphEdgeList& outputEdges,
|
cmGraphEdgeList& outputEdges,
|
||||||
cmGraphEdgeList const& inputEdges);
|
cmGraphEdgeList const& inputEdges);
|
||||||
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
|
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
|
||||||
void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
|
void AddInterfaceDepends(size_t depender_index,
|
||||||
|
cmLinkItem const& dependee_name,
|
||||||
const std::string& config,
|
const std::string& config,
|
||||||
std::set<cmLinkItem>& emitted);
|
std::set<cmLinkItem>& emitted);
|
||||||
void AddInterfaceDepends(int depender_index,
|
void AddInterfaceDepends(size_t depender_index,
|
||||||
cmGeneratorTarget const* dependee,
|
cmGeneratorTarget const* dependee,
|
||||||
cmListFileBacktrace const& dependee_backtrace,
|
cmListFileBacktrace const& dependee_backtrace,
|
||||||
const std::string& config,
|
const std::string& config,
|
||||||
std::set<cmLinkItem>& emitted);
|
std::set<cmLinkItem>& emitted);
|
||||||
void AddObjectDepends(int depender_index, cmSourceFile const* o,
|
void AddObjectDepends(size_t depender_index, cmSourceFile const* o,
|
||||||
std::set<cmLinkItem>& emitted);
|
std::set<cmLinkItem>& emitted);
|
||||||
cmGlobalGenerator* GlobalGenerator;
|
cmGlobalGenerator* GlobalGenerator;
|
||||||
bool DebugMode;
|
bool DebugMode;
|
||||||
@@ -80,7 +84,7 @@ private:
|
|||||||
|
|
||||||
// Collect all targets.
|
// Collect all targets.
|
||||||
std::vector<cmGeneratorTarget const*> Targets;
|
std::vector<cmGeneratorTarget const*> Targets;
|
||||||
std::map<cmGeneratorTarget const*, int> TargetIndex;
|
std::map<cmGeneratorTarget const*, size_t> TargetIndex;
|
||||||
|
|
||||||
// Represent the target dependency graph. The entry at each
|
// Represent the target dependency graph. The entry at each
|
||||||
// top-level index corresponds to a depender whose dependencies are
|
// top-level index corresponds to a depender whose dependencies are
|
||||||
@@ -99,11 +103,12 @@ private:
|
|||||||
void DisplayComponents(cmComputeComponentGraph const& ccg,
|
void DisplayComponents(cmComputeComponentGraph const& ccg,
|
||||||
const std::string& name);
|
const std::string& name);
|
||||||
bool CheckComponents(cmComputeComponentGraph const& ccg);
|
bool CheckComponents(cmComputeComponentGraph const& ccg);
|
||||||
void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c,
|
void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, size_t c,
|
||||||
bool strong = false);
|
bool strong = false);
|
||||||
|
|
||||||
std::vector<int> ComponentHead;
|
std::vector<size_t> ComponentHead;
|
||||||
std::vector<int> ComponentTail;
|
std::vector<size_t> ComponentTail;
|
||||||
bool IntraComponent(std::vector<int> const& cmap, int c, int i, int* head,
|
bool IntraComponent(std::vector<size_t> const& cmap, size_t c, size_t i,
|
||||||
std::set<int>& emitted, std::set<int>& visited);
|
size_t* head, std::set<size_t>& emitted,
|
||||||
|
std::set<size_t>& visited);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -17,14 +18,14 @@
|
|||||||
class cmGraphEdge
|
class cmGraphEdge
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmGraphEdge(int n, bool s, bool c, cmListFileBacktrace bt)
|
cmGraphEdge(size_t n, bool s, bool c, cmListFileBacktrace bt)
|
||||||
: Dest(n)
|
: Dest(n)
|
||||||
, Strong(s)
|
, Strong(s)
|
||||||
, Cross(c)
|
, Cross(c)
|
||||||
, Backtrace(std::move(bt))
|
, Backtrace(std::move(bt))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
operator int() const { return this->Dest; }
|
operator size_t() const { return this->Dest; }
|
||||||
|
|
||||||
bool IsStrong() const { return this->Strong; }
|
bool IsStrong() const { return this->Strong; }
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ public:
|
|||||||
cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
|
cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int Dest;
|
size_t Dest;
|
||||||
bool Strong;
|
bool Strong;
|
||||||
bool Cross;
|
bool Cross;
|
||||||
cmListFileBacktrace Backtrace;
|
cmListFileBacktrace Backtrace;
|
||||||
@@ -41,7 +42,7 @@ private:
|
|||||||
struct cmGraphEdgeList : public std::vector<cmGraphEdge>
|
struct cmGraphEdgeList : public std::vector<cmGraphEdge>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
struct cmGraphNodeList : public std::vector<int>
|
struct cmGraphNodeList : public std::vector<size_t>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
struct cmGraphAdjacencyList : public std::vector<cmGraphEdgeList>
|
struct cmGraphAdjacencyList : public std::vector<cmGraphEdgeList>
|
||||||
|
|||||||
Reference in New Issue
Block a user