diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-10-12 17:52:29 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-10-12 17:52:29 (GMT) |
commit | f18e7c7ff7935a93076384ba15629942f559cc8d (patch) | |
tree | 85b1a0bc3002c93654f58ec579e73d549b0eec27 /Source/cmDependsC.cxx | |
parent | a51dfefe796c1c7108d92e79dc77607c8307ef4b (diff) | |
download | CMake-f18e7c7ff7935a93076384ba15629942f559cc8d.zip CMake-f18e7c7ff7935a93076384ba15629942f559cc8d.tar.gz CMake-f18e7c7ff7935a93076384ba15629942f559cc8d.tar.bz2 |
ENH: Improve performance of check build system by creating another file that is simpler to parse and therefore much faster overall
Diffstat (limited to 'Source/cmDependsC.cxx')
-rw-r--r-- | Source/cmDependsC.cxx | 150 |
1 files changed, 6 insertions, 144 deletions
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 20c4ea8..905b964 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -45,8 +45,8 @@ cmDependsC::~cmDependsC() } //---------------------------------------------------------------------------- -bool cmDependsC::WriteDependencies(const char *src, - const char *obj, std::ostream& os) +bool cmDependsC::WriteDependencies(const char *src, const char *obj, + std::ostream& makeDepends, std::ostream& internalDepends) { // Make sure this is a scanning instance. if(!src || src[0] == '\0') @@ -161,89 +161,21 @@ bool cmDependsC::WriteDependencies(const char *src, } // Write the dependencies to the output stream. + internalDepends << obj << std::endl; for(std::set<cmStdString>::iterator i=dependencies.begin(); i != dependencies.end(); ++i) { - os << obj << ": " + makeDepends << obj << ": " << cmSystemTools::ConvertToOutputPath(i->c_str()).c_str() << std::endl; + internalDepends << " " << i->c_str() << std::endl; } - os << std::endl; + makeDepends << std::endl; return true; } //---------------------------------------------------------------------------- -bool cmDependsC::CheckDependencies(std::istream& is) -{ - // Parse dependencies from the stream. If any dependee is missing - // or newer than the depender then dependencies should be - // regenerated. - bool okay = true; - std::string line; - std::string depender; - std::string dependee; - while(cmSystemTools::GetLineFromStream(is, line)) - { - // Parse the dependency line. - if(!this->ParseDependency(line.c_str(), depender, dependee)) - { - continue; - } - - // Dependencies must be regenerated if the dependee does not exist - // or if the depender exists and is older than the dependee. - bool regenerate = false; - if(!cmSystemTools::FileExists(dependee.c_str())) - { - // The dependee does not exist. - regenerate = true; - - // Print verbose output. - if(m_Verbose) - { - cmOStringStream msg; - msg << "Dependee \"" << dependee - << "\" does not exist for depender \"" - << depender << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); - } - } - else if(cmSystemTools::FileExists(depender.c_str())) - { - // The dependee and depender both exist. Compare file times. - int result = 0; - if((!cmSystemTools::FileTimeCompare(depender.c_str(), dependee.c_str(), - &result) || result < 0)) - { - // The depender is older than the dependee. - regenerate = true; - - // Print verbose output. - if(m_Verbose) - { - cmOStringStream msg; - msg << "Dependee \"" << dependee - << "\" is newer than depender \"" - << depender << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); - } - } - } - if(regenerate) - { - // Dependencies must be regenerated. - okay = false; - - // Remove the depender to be sure it is rebuilt. - cmSystemTools::RemoveFile(depender.c_str()); - } - } - - return okay; -} - -//---------------------------------------------------------------------------- void cmDependsC::Scan(std::istream& is, const char* directory) { // Read one line at a time. @@ -283,76 +215,6 @@ void cmDependsC::Scan(std::istream& is, const char* directory) } //---------------------------------------------------------------------------- -bool cmDependsC::ParseDependency(const char* line, std::string& depender, - std::string& dependee) -{ - // Start with empty names. - depender = ""; - dependee = ""; - - // Get the left-hand-side of the dependency. - const char* c = this->ParseFileName(line, depender); - - // Skip the ':' separator. - for(;c && *c && isspace(*c);++c); - if(!c || !*c || *c != ':') - { - return false; - } - ++c; - - // Get the right-hand-side of the dependency. - return this->ParseFileName(c, dependee)?true:false; -} - -//---------------------------------------------------------------------------- -const char* cmDependsC::ParseFileName(const char* in, std::string& name) -{ - // Skip leading whitespace. - const char* c = in; - for(;c && *c && isspace(*c);++c); - - // If this is an empty line or a comment line return failure. - if(!c || !*c || *c == '#') - { - return 0; - } - - // Parse the possibly quoted file name. - bool quoted = false; - char* buf = new char[strlen(in)+1]; - char* pos = buf; - - // for every character while we haven't hit the end of the string AND we - // are in a quoted string OR the current character isn't a : or the second - // character AND it isn't a space - for(;*c && (quoted || - ((*c != ':' || pos == buf+1) && !isspace(*c))); ++c) - { - if(*c == '"') - { - quoted = !quoted; - } - // handle unquoted escaped spaces - else if(!quoted && *c == '\\' && isspace(*(c+1))) - { - *pos = *(++c); - pos++; - } - else - { - *pos = *c; - pos++; - } - } - *pos =0; - name += buf; - delete [] buf; - // Return the ending position. - return c; -} - -//---------------------------------------------------------------------------- bool cmDependsC::FileExistsOrIsGenerated(const std::string& fname, std::set<cmStdString>& scanned, std::set<cmStdString>& dependencies) |