BUG: Patch from Alex to recompute dependencies when the include regex changes. This addresses bug#4168.

This commit is contained in:
Brad King 2007-02-05 09:48:38 -05:00
parent 9e61ee2bed
commit 6bba86c8c8
2 changed files with 43 additions and 2 deletions

View File

@ -22,6 +22,13 @@
#include <ctype.h> // isspace #include <ctype.h> // isspace
#define INCLUDE_REGEX_LINE "^[ \t]*#[ \t]*(include|import)[ \t]*[<\"]([^\">]+)([\">])"
#define INCLUDE_REGEX_LINE_MARKER "#IncludeRegexLine: "
#define INCLUDE_REGEX_SCAN_MARKER "#IncludeRegexScan: "
#define INCLUDE_REGEX_COMPLAIN_MARKER "#IncludeRegexComplain: "
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsC::cmDependsC(): cmDependsC::cmDependsC():
IncludePath(0) IncludePath(0)
@ -33,10 +40,12 @@ cmDependsC::cmDependsC(std::vector<std::string> const& includes,
const char* scanRegex, const char* complainRegex, const char* scanRegex, const char* complainRegex,
const cmStdString& cacheFileName): const cmStdString& cacheFileName):
IncludePath(&includes), IncludePath(&includes),
IncludeRegexLine( IncludeRegexLine(INCLUDE_REGEX_LINE),
"^[ \t]*#[ \t]*(include|import)[ \t]*[<\"]([^\">]+)([\">])"),
IncludeRegexScan(scanRegex), IncludeRegexScan(scanRegex),
IncludeRegexComplain(complainRegex), IncludeRegexComplain(complainRegex),
IncludeRegexLineString(INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE),
IncludeRegexScanString(std::string(INCLUDE_REGEX_SCAN_MARKER)+scanRegex),
IncludeRegexComplainString(std::string(INCLUDE_REGEX_COMPLAIN_MARKER)+complainRegex),
CacheFileName(cacheFileName) CacheFileName(cacheFileName)
{ {
this->ReadCacheFile(); this->ReadCacheFile();
@ -281,6 +290,31 @@ void cmDependsC::ReadCacheFile()
cacheEntry=new cmIncludeLines; cacheEntry=new cmIncludeLines;
this->FileCache[line]=cacheEntry; this->FileCache[line]=cacheEntry;
} }
// file doesn't exist, check that the regular expressions haven't changed
else if (res==false)
{
if (line.find(INCLUDE_REGEX_LINE_MARKER) == 0)
{
if (line != this->IncludeRegexLineString)
{
return;
}
}
else if (line.find(INCLUDE_REGEX_SCAN_MARKER) == 0)
{
if (line != this->IncludeRegexScanString)
{
return;
}
}
else if (line.find(INCLUDE_REGEX_COMPLAIN_MARKER) == 0)
{
if (line != this->IncludeRegexComplainString)
{
return;
}
}
}
} }
else if (cacheEntry!=0) else if (cacheEntry!=0)
{ {
@ -311,6 +345,10 @@ void cmDependsC::WriteCacheFile() const
return; return;
} }
cacheOut << this->IncludeRegexLineString << "\n\n";
cacheOut << this->IncludeRegexScanString << "\n\n";
cacheOut << this->IncludeRegexComplainString << "\n\n";
for (std::map<cmStdString, cmIncludeLines*>::const_iterator fileIt= for (std::map<cmStdString, cmIncludeLines*>::const_iterator fileIt=
this->FileCache.begin(); this->FileCache.begin();
fileIt!=this->FileCache.end(); ++fileIt) fileIt!=this->FileCache.end(); ++fileIt)

View File

@ -60,6 +60,9 @@ protected:
// recursively and which to complain about not finding. // recursively and which to complain about not finding.
cmsys::RegularExpression IncludeRegexScan; cmsys::RegularExpression IncludeRegexScan;
cmsys::RegularExpression IncludeRegexComplain; cmsys::RegularExpression IncludeRegexComplain;
const std::string IncludeRegexLineString;
const std::string IncludeRegexScanString;
const std::string IncludeRegexComplainString;
public: public:
// Data structures for dependency graph walk. // Data structures for dependency graph walk.