Merge topic 'reduce-realpath-calls'
4e3cf8b0
cmOrderDirectories: Reduce repeat realpath() calls6b185287
cmOrderDirectories: Factor out directory comparison
This commit is contained in:
commit
5257a3b931
|
@ -73,10 +73,8 @@ public:
|
||||||
{
|
{
|
||||||
// Check if this directory conflicts with the entry.
|
// Check if this directory conflicts with the entry.
|
||||||
std::string const& dir = this->OD->OriginalDirectories[i];
|
std::string const& dir = this->OD->OriginalDirectories[i];
|
||||||
if(dir != this->Directory &&
|
if (!this->OD->IsSameDirectory(dir, this->Directory) &&
|
||||||
cmSystemTools::GetRealPath(dir) !=
|
this->FindConflict(dir))
|
||||||
cmSystemTools::GetRealPath(this->Directory) &&
|
|
||||||
this->FindConflict(dir))
|
|
||||||
{
|
{
|
||||||
// The library will be found in this directory but this is not
|
// The library will be found in this directory but this is not
|
||||||
// the directory named for it. Add an entry to make sure the
|
// the directory named for it. Add an entry to make sure the
|
||||||
|
@ -639,3 +637,23 @@ void cmOrderDirectories::DiagnoseCycle()
|
||||||
->IssueMessage(cmake::WARNING, e.str(),
|
->IssueMessage(cmake::WARNING, e.str(),
|
||||||
this->Target->GetBacktrace());
|
this->Target->GetBacktrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmOrderDirectories::IsSameDirectory(std::string const& l,
|
||||||
|
std::string const& r)
|
||||||
|
{
|
||||||
|
return this->GetRealPath(l) == this->GetRealPath(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string const& cmOrderDirectories::GetRealPath(std::string const& dir)
|
||||||
|
{
|
||||||
|
std::map<std::string, std::string>::iterator i =
|
||||||
|
this->RealPaths.lower_bound(dir);
|
||||||
|
if (i == this->RealPaths.end() ||
|
||||||
|
this->RealPaths.key_comp()(dir, i->first))
|
||||||
|
{
|
||||||
|
typedef std::map<std::string, std::string>::value_type value_type;
|
||||||
|
i = this->RealPaths.insert(
|
||||||
|
i, value_type(dir, cmSystemTools::GetRealPath(dir)));
|
||||||
|
}
|
||||||
|
return i->second;
|
||||||
|
}
|
||||||
|
|
|
@ -80,6 +80,12 @@ private:
|
||||||
struct ConflictList: public std::vector<ConflictPair> {};
|
struct ConflictList: public std::vector<ConflictPair> {};
|
||||||
std::vector<ConflictList> ConflictGraph;
|
std::vector<ConflictList> ConflictGraph;
|
||||||
|
|
||||||
|
// Compare directories after resolving symlinks.
|
||||||
|
bool IsSameDirectory(std::string const& l, std::string const& r);
|
||||||
|
|
||||||
|
std::string const& GetRealPath(std::string const& dir);
|
||||||
|
std::map<std::string, std::string> RealPaths;
|
||||||
|
|
||||||
friend class cmOrderDirectoriesConstraint;
|
friend class cmOrderDirectoriesConstraint;
|
||||||
friend class cmOrderDirectoriesConstraintLibrary;
|
friend class cmOrderDirectoriesConstraintLibrary;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue