| 691 | } |
| 692 | |
| 693 | bool cmComputeTargetDepends::ComputeFinalDepends( |
| 694 | cmComputeComponentGraph const& ccg) |
| 695 | { |
| 696 | // Get the component graph information. |
| 697 | std::vector<NodeList> const& components = ccg.GetComponents(); |
| 698 | Graph const& cgraph = ccg.GetComponentGraph(); |
| 699 | |
| 700 | // Allocate the final graph. |
| 701 | this->FinalGraph.resize(0); |
| 702 | this->FinalGraph.resize(this->InitialGraph.size()); |
| 703 | |
| 704 | // Choose intra-component edges to linearize dependencies. |
| 705 | std::vector<size_t> const& cmap = ccg.GetComponentMap(); |
| 706 | this->ComponentHead.resize(components.size()); |
| 707 | this->ComponentTail.resize(components.size()); |
| 708 | size_t nc = components.size(); |
| 709 | for (size_t c = 0; c < nc; ++c) { |
| 710 | size_t head = cmComputeComponentGraph::INVALID_COMPONENT; |
| 711 | std::set<size_t> emitted; |
| 712 | NodeList const& nl = components[c]; |
| 713 | for (size_t ni : cmReverseRange(nl)) { |
| 714 | std::set<size_t> visited; |
| 715 | if (!this->IntraComponent(cmap, c, ni, &head, emitted, visited)) { |
| 716 | // Cycle in add_dependencies within component! |
| 717 | this->ComplainAboutBadComponent(ccg, c, true); |
| 718 | return false; |
| 719 | } |
| 720 | } |
| 721 | this->ComponentHead[c] = head; |
| 722 | } |
| 723 | |
| 724 | // Convert inter-component edges to connect component tails to heads. |
| 725 | size_t n = cgraph.size(); |
| 726 | for (size_t depender_component = 0; depender_component < n; |
| 727 | ++depender_component) { |
| 728 | size_t depender_component_tail = this->ComponentTail[depender_component]; |
| 729 | EdgeList const& nl = cgraph[depender_component]; |
| 730 | for (cmGraphEdge const& ni : nl) { |
| 731 | size_t dependee_component = ni; |
| 732 | size_t dependee_component_head = this->ComponentHead[dependee_component]; |
| 733 | this->FinalGraph[depender_component_tail].emplace_back( |
| 734 | dependee_component_head, ni.IsStrong(), ni.IsCross(), |
| 735 | ni.GetBacktrace()); |
| 736 | } |
| 737 | } |
| 738 | return true; |
| 739 | } |
no test coverage detected