2009-10-02 01:21: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-10-02 01:21: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-10-02 01:21: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 cmLocalGenerator;
|
|
|
|
class cmMakefile;
|
|
|
|
class cmTarget;
|
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:
|
|
|
|
cmComputeLinkDepends(cmTarget* target, const char* config);
|
|
|
|
~cmComputeLinkDepends();
|
|
|
|
|
|
|
|
// Basic information about each link item.
|
|
|
|
struct LinkEntry
|
|
|
|
{
|
|
|
|
std::string Item;
|
|
|
|
cmTarget* 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);
|
|
|
|
std::set<cmTarget*> const& GetOldWrongConfigItems() const
|
|
|
|
{ return this->OldWrongConfigItems; }
|
|
|
|
|
2008-01-27 21:42:49 +03:00
|
|
|
private:
|
|
|
|
|
|
|
|
// Context information.
|
|
|
|
cmTarget* Target;
|
|
|
|
cmMakefile* Makefile;
|
|
|
|
cmLocalGenerator* LocalGenerator;
|
|
|
|
cmGlobalGenerator* GlobalGenerator;
|
2008-03-13 23:35:39 +03:00
|
|
|
cmake* CMakeInstance;
|
2008-01-27 21:42:49 +03:00
|
|
|
bool DebugMode;
|
|
|
|
|
|
|
|
// Configuration information.
|
|
|
|
const char* Config;
|
2008-09-05 01:34:25 +04:00
|
|
|
cmTarget::LinkLibraryType LinkType;
|
2008-01-27 21:42:49 +03:00
|
|
|
|
|
|
|
// Output information.
|
|
|
|
EntryVector FinalLinkEntries;
|
|
|
|
|
|
|
|
typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType;
|
|
|
|
|
2008-01-31 23:45:31 +03:00
|
|
|
std::map<cmStdString, int>::iterator
|
|
|
|
AllocateLinkEntry(std::string const& item);
|
2009-04-06 19:10:37 +04:00
|
|
|
int AddLinkEntry(int depender_index, std::string 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();
|
2008-01-27 21:42:49 +03:00
|
|
|
void AddLinkEntries(int depender_index,
|
2008-01-28 16:38:36 +03:00
|
|
|
std::vector<std::string> const& libs);
|
2009-04-06 19:10:37 +04:00
|
|
|
cmTarget* FindTargetToLink(int depender_index, const char* name);
|
2008-01-27 21:42:49 +03:00
|
|
|
|
|
|
|
// One entry for each unique item.
|
|
|
|
std::vector<LinkEntry> EntryList;
|
|
|
|
std::map<cmStdString, int> LinkEntryIndex;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
{
|
|
|
|
std::string Item;
|
|
|
|
int DependerIndex;
|
|
|
|
};
|
|
|
|
std::queue<SharedDepEntry> SharedDepQueue;
|
|
|
|
void QueueSharedDependencies(int depender_index,
|
|
|
|
std::vector<std::string> const& deps);
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
int ComponentOrderId;
|
|
|
|
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;
|
|
|
|
|
2008-03-31 20:47:31 +04:00
|
|
|
// Compatibility help.
|
|
|
|
bool OldLinkDirMode;
|
2009-04-06 19:10:37 +04:00
|
|
|
void CheckWrongConfigItem(int depender_index, std::string const& item);
|
2008-03-31 20:47:31 +04:00
|
|
|
std::set<cmTarget*> OldWrongConfigItems;
|
2008-01-27 21:42:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|