ENH: Add RecurseThroughSymlinks data member to kwsys::Glob. Allows recursive globs to skip symlinks when necessary. Default to true for backwards compatible behavior. Used from the ctest coverage handler to avoid recursing through the '/Applications' directory on the Mac looking for *.da files... Should fix the hangs reported recently by Mac CMake dashboard submitters.
This commit is contained in:
parent
fff812db95
commit
86e7a9dad8
|
@ -685,6 +685,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
|
||||||
|
|
||||||
cmsys::Glob gl;
|
cmsys::Glob gl;
|
||||||
gl.RecurseOn();
|
gl.RecurseOn();
|
||||||
|
gl.RecurseThroughSymlinksOff();
|
||||||
std::string daGlob = cont->BinaryDir + "/*.da";
|
std::string daGlob = cont->BinaryDir + "/*.da";
|
||||||
gl.FindFiles(daGlob);
|
gl.FindFiles(daGlob);
|
||||||
std::vector<std::string> files = gl.GetFiles();
|
std::vector<std::string> files = gl.GetFiles();
|
||||||
|
@ -1054,6 +1055,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
|
||||||
{
|
{
|
||||||
cmsys::Glob gl;
|
cmsys::Glob gl;
|
||||||
gl.RecurseOn();
|
gl.RecurseOn();
|
||||||
|
gl.RecurseThroughSymlinksOff();
|
||||||
std::string daGlob = cont->BinaryDir + "/*.cover";
|
std::string daGlob = cont->BinaryDir + "/*.cover";
|
||||||
gl.FindFiles(daGlob);
|
gl.FindFiles(daGlob);
|
||||||
std::vector<std::string> files = gl.GetFiles();
|
std::vector<std::string> files = gl.GetFiles();
|
||||||
|
|
|
@ -63,6 +63,10 @@ Glob::Glob()
|
||||||
this->Internals = new GlobInternals;
|
this->Internals = new GlobInternals;
|
||||||
this->Recurse = false;
|
this->Recurse = false;
|
||||||
this->Relative = "";
|
this->Relative = "";
|
||||||
|
|
||||||
|
this->RecurseThroughSymlinks = true;
|
||||||
|
// RecurseThroughSymlinks is true by default for backwards compatibility,
|
||||||
|
// not because it's a good idea...
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -262,7 +266,11 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
|
||||||
}
|
}
|
||||||
if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) )
|
if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) )
|
||||||
{
|
{
|
||||||
this->RecurseDirectory(start+1, realname, dir_only);
|
if (!kwsys::SystemTools::FileIsSymlink(realname.c_str()) ||
|
||||||
|
this->RecurseThroughSymlinks)
|
||||||
|
{
|
||||||
|
this->RecurseDirectory(start+1, realname, dir_only);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,13 @@ public:
|
||||||
void SetRecurse(bool i) { this->Recurse = i; }
|
void SetRecurse(bool i) { this->Recurse = i; }
|
||||||
bool GetRecurse() { return this->Recurse; }
|
bool GetRecurse() { return this->Recurse; }
|
||||||
|
|
||||||
|
//! Set recurse through symlinks to true if recursion should traverse the
|
||||||
|
// linked-to directories
|
||||||
|
void RecurseThroughSymlinksOn() { this->SetRecurseThroughSymlinks(true); }
|
||||||
|
void RecurseThroughSymlinksOff() { this->SetRecurseThroughSymlinks(false); }
|
||||||
|
void SetRecurseThroughSymlinks(bool i) { this->RecurseThroughSymlinks = i; }
|
||||||
|
bool GetRecurseThroughSymlinks() { return this->RecurseThroughSymlinks; }
|
||||||
|
|
||||||
//! Set relative to true to only show relative path to files.
|
//! Set relative to true to only show relative path to files.
|
||||||
void SetRelative(const char* dir);
|
void SetRelative(const char* dir);
|
||||||
const char* GetRelative();
|
const char* GetRelative();
|
||||||
|
@ -90,6 +97,7 @@ protected:
|
||||||
GlobInternals* Internals;
|
GlobInternals* Internals;
|
||||||
bool Recurse;
|
bool Recurse;
|
||||||
kwsys_stl::string Relative;
|
kwsys_stl::string Relative;
|
||||||
|
bool RecurseThroughSymlinks;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Glob(const Glob&); // Not implemented.
|
Glob(const Glob&); // Not implemented.
|
||||||
|
|
Loading…
Reference in New Issue