2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-01-27 21:42:49 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-01-27 21:42:49 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2008-01-27 21:42:49 +03:00
|
|
|
#ifndef cmComputeLinkDepends_h
|
|
|
|
#define cmComputeLinkDepends_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
#include "cmTarget.h"
|
|
|
|
|
2008-02-08 00:14:05 +03:00
|
|
|
#include "cmGraphAdjacencyList.h"
|
|
|
|
|
2008-01-27 21:42:49 +03:00
|
|
|
#include <queue>
|
|
|
|
|
2008-02-08 00:14:05 +03:00
|
|
|
class cmComputeComponentGraph;
|
2008-01-27 21:42:49 +03:00
|
|
|
class cmGlobalGenerator;
|
|
|
|
class cmMakefile;
|
2015-08-04 20:19:50 +03:00
|
|
|
class cmGeneratorTarget;
|
2008-03-13 23:35:39 +03:00
|
|
|
class cmake;
|
2008-01-27 21:42:49 +03:00
|
|
|
|
|
|
|
/** \class cmComputeLinkDepends
|
|
|
|
* \brief Compute link dependencies for targets.
|
|
|
|
*/
|
|
|
|
class cmComputeLinkDepends
|
|
|
|
{
|
|
|
|
public:
|
2015-08-04 20:19:50 +03:00
|
|
|
cmComputeLinkDepends(cmGeneratorTarget const* target,
|
|
|
|
const std::string& config);
|
2008-01-27 21:42:49 +03:00
|
|
|
~cmComputeLinkDepends();
|
|
|
|
|
|
|
|
// Basic information about each link item.
|
|
|
|
struct LinkEntry
|
|
|
|
{
|
|
|
|
std::string Item;
|
2015-10-08 01:41:15 +03:00
|
|
|
cmGeneratorTarget const* Target;
|
2008-01-31 23:45:31 +03:00
|
|
|
bool IsSharedDep;
|
2008-08-27 18:21:50 +04:00
|
|
|
bool IsFlag;
|
|
|
|
LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {}
|
2008-01-31 23:45:31 +03:00
|
|
|
LinkEntry(LinkEntry const& r):
|
2008-08-27 18:21:50 +04:00
|
|
|
Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep),
|
|
|
|
IsFlag(r.IsFlag) {}
|
2008-01-27 21:42:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<LinkEntry> EntryVector;
|
|
|
|
EntryVector const& Compute();
|
|
|
|
|
2008-03-31 20:47:31 +04:00
|
|
|
void SetOldLinkDirMode(bool b);
|
2013-12-10 18:30:41 +04:00
|
|
|
std::set<cmTarget const*> const& GetOldWrongConfigItems() const
|
2008-03-31 20:47:31 +04:00
|
|
|
{ return this->OldWrongConfigItems; }
|
|
|
|
|
2008-01-27 21:42:49 +03:00
|
|
|
private:
|
|
|
|
|
|
|
|
// Context information.
|
2015-08-04 20:19:50 +03:00
|
|
|
cmGeneratorTarget const* Target;
|
2008-01-27 21:42:49 +03:00
|
|
|
cmMakefile* Makefile;
|
2014-01-10 16:14:29 +04:00
|
|
|
cmGlobalGenerator const* GlobalGenerator;
|
2008-03-13 23:35:39 +03:00
|
|
|
cmake* CMakeInstance;
|
2014-02-10 07:48:34 +04:00
|
|
|
std::string Config;
|
2008-01-27 21:42:49 +03:00
|
|
|
EntryVector FinalLinkEntries;
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::map<std::string, int>::iterator
|
2008-01-31 23:45:31 +03:00
|
|
|
AllocateLinkEntry(std::string const& item);
|
2014-06-16 19:49:10 +04:00
|
|
|
int AddLinkEntry(cmLinkItem const& item);
|
2008-01-27 21:42:49 +03:00
|
|
|
void AddVarLinkEntries(int depender_index, const char* value);
|
2009-07-07 00:25:20 +04:00
|
|
|
void AddDirectLinkEntries();
|
2014-06-30 18:28:08 +04:00
|
|
|
template <typename T>
|
|
|
|
void AddLinkEntries(int depender_index, std::vector<T> const& libs);
|
2014-02-07 02:31:47 +04:00
|
|
|
cmTarget const* FindTargetToLink(int depender_index,
|
|
|
|
const std::string& name);
|
2008-01-27 21:42:49 +03:00
|
|
|
|
|
|
|
// One entry for each unique item.
|
|
|
|
std::vector<LinkEntry> EntryList;
|
2014-02-10 09:21:34 +04:00
|
|
|
std::map<std::string, int> LinkEntryIndex;
|
2008-01-27 21:42:49 +03:00
|
|
|
|
|
|
|
// BFS of initial dependencies.
|
|
|
|
struct BFSEntry
|
|
|
|
{
|
|
|
|
int Index;
|
|
|
|
const char* LibDepends;
|
|
|
|
};
|
|
|
|
std::queue<BFSEntry> BFSQueue;
|
|
|
|
void FollowLinkEntry(BFSEntry const&);
|
|
|
|
|
2008-01-31 23:45:31 +03:00
|
|
|
// Shared libraries that are included only because they are
|
|
|
|
// dependencies of other shared libraries, not because they are part
|
|
|
|
// of the interface.
|
|
|
|
struct SharedDepEntry
|
|
|
|
{
|
2014-06-16 19:49:10 +04:00
|
|
|
cmLinkItem Item;
|
2008-01-31 23:45:31 +03:00
|
|
|
int DependerIndex;
|
|
|
|
};
|
|
|
|
std::queue<SharedDepEntry> SharedDepQueue;
|
2012-01-12 19:22:00 +04:00
|
|
|
std::set<int> SharedDepFollowed;
|
|
|
|
void FollowSharedDeps(int depender_index,
|
2015-08-26 20:35:45 +03:00
|
|
|
cmLinkInterface const* iface,
|
2012-01-12 19:22:00 +04:00
|
|
|
bool follow_interface = false);
|
2008-01-31 23:45:31 +03:00
|
|
|
void QueueSharedDependencies(int depender_index,
|
2014-06-16 19:49:10 +04:00
|
|
|
std::vector<cmLinkItem> const& deps);
|
2008-01-31 23:45:31 +03:00
|
|
|
void HandleSharedDependency(SharedDepEntry const& dep);
|
|
|
|
|
2008-01-27 21:42:49 +03:00
|
|
|
// Dependency inferral for each link item.
|
|
|
|
struct DependSet: public std::set<int> {};
|
|
|
|
struct DependSetList: public std::vector<DependSet> {};
|
|
|
|
std::vector<DependSetList*> InferredDependSets;
|
|
|
|
void InferDependencies();
|
|
|
|
|
|
|
|
// Ordering constraint graph adjacency list.
|
2008-02-08 00:14:05 +03:00
|
|
|
typedef cmGraphNodeList NodeList;
|
2010-08-20 22:11:18 +04:00
|
|
|
typedef cmGraphEdgeList EdgeList;
|
2008-02-08 00:14:05 +03:00
|
|
|
typedef cmGraphAdjacencyList Graph;
|
|
|
|
Graph EntryConstraintGraph;
|
|
|
|
void CleanConstraintGraph();
|
2008-01-27 21:42:49 +03:00
|
|
|
void DisplayConstraintGraph();
|
|
|
|
|
|
|
|
// Ordering algorithm.
|
|
|
|
void OrderLinkEntires();
|
2008-02-08 00:14:05 +03:00
|
|
|
std::vector<char> ComponentVisited;
|
2008-08-27 18:21:57 +04:00
|
|
|
std::vector<int> ComponentOrder;
|
2015-06-07 11:41:16 +03:00
|
|
|
|
2008-08-27 18:21:57 +04:00
|
|
|
struct PendingComponent
|
|
|
|
{
|
|
|
|
// The real component id. Needed because the map is indexed by
|
|
|
|
// component topological index.
|
|
|
|
int Id;
|
|
|
|
|
|
|
|
// The number of times the component needs to be seen. This is
|
|
|
|
// always 1 for trivial components and is initially 2 for
|
|
|
|
// non-trivial components.
|
|
|
|
int Count;
|
|
|
|
|
|
|
|
// The entries yet to be seen to complete the component.
|
2008-08-27 18:35:53 +04:00
|
|
|
std::set<int> Entries;
|
2008-08-27 18:21:57 +04:00
|
|
|
};
|
|
|
|
std::map<int, PendingComponent> PendingComponents;
|
|
|
|
cmComputeComponentGraph* CCG;
|
2008-04-23 08:40:19 +04:00
|
|
|
std::vector<int> FinalLinkOrder;
|
2008-08-27 18:21:57 +04:00
|
|
|
void DisplayComponents();
|
|
|
|
void VisitComponent(unsigned int c);
|
|
|
|
void VisitEntry(int index);
|
|
|
|
PendingComponent& MakePendingComponent(unsigned int component);
|
2009-09-01 18:37:37 +04:00
|
|
|
int ComputeComponentCount(NodeList const& nl);
|
2008-01-27 21:42:49 +03:00
|
|
|
void DisplayFinalEntries();
|
2008-03-31 20:47:31 +04:00
|
|
|
|
2008-08-27 18:21:57 +04:00
|
|
|
// Record of the original link line.
|
2008-04-23 08:40:19 +04:00
|
|
|
std::vector<int> OriginalEntries;
|
2015-06-07 11:41:16 +03:00
|
|
|
std::set<cmTarget const*> OldWrongConfigItems;
|
|
|
|
void CheckWrongConfigItem(cmLinkItem const& item);
|
2008-04-23 08:40:19 +04:00
|
|
|
|
2015-06-07 11:41:16 +03:00
|
|
|
int ComponentOrderId;
|
|
|
|
cmTarget::LinkLibraryType LinkType;
|
|
|
|
bool HasConfig;
|
|
|
|
bool DebugMode;
|
2008-03-31 20:47:31 +04:00
|
|
|
bool OldLinkDirMode;
|
2008-01-27 21:42:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|