MCPcopy Create free account
hub / github.com/Kitware/CMake / OrderLinkEntries

Method OrderLinkEntries

Source/cmComputeLinkDepends.cxx:1470–1520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1468}
1469
1470void cmComputeLinkDepends::OrderLinkEntries()
1471{
1472 // The component graph is guaranteed to be acyclic. Start a DFS
1473 // from every entry to compute a topological order for the
1474 // components.
1475 Graph const& cgraph = this->CCG->GetComponentGraph();
1476 size_t n = cgraph.size();
1477 this->ComponentVisited.resize(cgraph.size(), 0);
1478 this->ComponentOrder.resize(cgraph.size(), n);
1479 this->ComponentOrderId = n;
1480 // Run in reverse order so the topological order will preserve the
1481 // original order where there are no constraints.
1482 for (size_t c = n; c > 0; --c) {
1483 this->VisitComponent(c - 1);
1484 }
1485
1486 // Display the component graph.
1487 if (this->DebugMode) {
1488 this->DisplayComponents();
1489 }
1490
1491 // Start with the original link line.
1492 switch (this->Strategy) {
1493 case LinkLibrariesStrategy::REORDER_MINIMALLY: {
1494 // Emit the direct dependencies in their original order.
1495 // This gives projects control over ordering.
1496 for (size_t originalEntry : this->OriginalEntries) {
1497 this->VisitEntry(originalEntry);
1498 }
1499 } break;
1500 case LinkLibrariesStrategy::REORDER_FREELY: {
1501 // Schedule the direct dependencies for emission in topo order.
1502 // This may produce more efficient link lines.
1503 for (size_t originalEntry : this->OriginalEntries) {
1504 this->MakePendingComponent(
1505 this->CCG->GetComponentMap()[originalEntry]);
1506 }
1507 } break;
1508 }
1509
1510 // Now explore anything left pending. Since the component graph is
1511 // guaranteed to be acyclic we know this will terminate.
1512 while (!this->PendingComponents.empty()) {
1513 // Visit one entry from the first pending component. The visit
1514 // logic will update the pending components accordingly. Since
1515 // the pending components are kept in topological order this will
1516 // not repeat one.
1517 size_t e = *this->PendingComponents.begin()->second.Entries.begin();
1518 this->VisitEntry(e);
1519 }
1520}
1521
1522void cmComputeLinkDepends::DisplayComponents()
1523{

Callers 1

Calls 7

VisitComponentMethod · 0.95
DisplayComponentsMethod · 0.95
VisitEntryMethod · 0.95
sizeMethod · 0.45
resizeMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected