2008-01-27 21:42:49 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#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;
|
|
|
|
|
|
|
|
/** \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;
|
|
|
|
LinkEntry(): Item(), Target(0), IsSharedDep(false) {}
|
|
|
|
LinkEntry(LinkEntry const& r):
|
|
|
|
Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep) {}
|
2008-01-27 21:42:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<LinkEntry> EntryVector;
|
|
|
|
EntryVector const& Compute();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// Context information.
|
|
|
|
cmTarget* Target;
|
|
|
|
cmMakefile* Makefile;
|
|
|
|
cmLocalGenerator* LocalGenerator;
|
|
|
|
cmGlobalGenerator* GlobalGenerator;
|
|
|
|
bool DebugMode;
|
|
|
|
|
|
|
|
// Configuration information.
|
|
|
|
const char* Config;
|
|
|
|
|
|
|
|
// 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);
|
2008-01-27 21:42:49 +03:00
|
|
|
int AddLinkEntry(std::string const& item);
|
|
|
|
void AddVarLinkEntries(int depender_index, const char* value);
|
2008-01-28 16:38:36 +03:00
|
|
|
void AddTargetLinkEntries(int depender_index,
|
|
|
|
LinkLibraryVectorType const& libs);
|
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);
|
2008-02-13 23:29:55 +03:00
|
|
|
std::string CleanItemName(std::string const& item);
|
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;
|
|
|
|
void DisplayComponents(cmComputeComponentGraph const& ccg);
|
|
|
|
void VisitComponent(cmComputeComponentGraph const& ccg, unsigned int i);
|
|
|
|
void EmitComponent(NodeList const& nl);
|
2008-01-27 21:42:49 +03:00
|
|
|
void DisplayFinalEntries();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|