automoc: move the code for finding headers into separate function

Alex
This commit is contained in:
Alex Neundorf 2011-12-02 20:38:14 +01:00
parent 8507eaed16
commit 174bf35fbb
2 changed files with 37 additions and 21 deletions

View File

@ -469,6 +469,23 @@ bool cmQtAutomoc::RunAutomocQt4()
std::vector<std::string> sourceFiles;
cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
std::list<std::string> headerExtensions;
headerExtensions.push_back(".h");
headerExtensions.push_back(".hpp");
headerExtensions.push_back(".hxx");
#if defined(_WIN32)
// not case sensitive, don't add ".H"
#elif defined(__APPLE__)
// detect case-sensitive filesystem
long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE);
if (caseSensitive == 1)
{
headerExtensions.push_back(".H");
}
#else
headerExtensions.push_back(".H");
#endif
for (std::vector<std::string>::const_iterator it = sourceFiles.begin();
it != sourceFiles.end();
++it)
@ -478,7 +495,8 @@ bool cmQtAutomoc::RunAutomocQt4()
{
std::cout << "AUTOMOC: Checking " << absFilename << std::endl;
}
this->ParseCppFile(absFilename, includedMocs, headerFiles);
this->ParseCppFile(absFilename, headerExtensions, includedMocs);
this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
}
std::vector<std::string> headerFilesVec;
@ -559,28 +577,12 @@ bool cmQtAutomoc::RunAutomocQt4()
void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
std::map<std::string, std::string>& includedMocs,
std::set<std::string>& absHeaders)
const std::list<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs)
{
cmsys::RegularExpression mocIncludeRegExp(
"[\n][ \t]*#[ \t]*include[ \t]+"
"[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
std::list<std::string> headerExtensions;
headerExtensions.push_back(".h");
headerExtensions.push_back(".hpp");
headerExtensions.push_back(".hxx");
#if defined(_WIN32)
// not case sensitive, don't add ".H"
#elif defined(__APPLE__)
// detect case-sensitive filesystem
long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE);
if (caseSensitive == 1)
{
headerExtensions.push_back(".H");
}
#else
headerExtensions.push_back(".H");
#endif
const std::string contentsString = this->ReadAll(absFilename);
if (contentsString.empty())
@ -771,9 +773,19 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
}
}
}
void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename,
const std::list<std::string>& headerExtensions,
std::set<std::string>& absHeaders)
{
// search for header files and private header files we may need to moc:
const std::string basename =
cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
ext != headerExtensions.end();
++ext)

View File

@ -39,8 +39,12 @@ private:
bool GenerateMoc(const std::string& sourceFile,
const std::string& mocFileName);
void ParseCppFile(const std::string& absFilename,
std::map<std::string, std::string>& includedMocs,
std::set<std::string>& absHeaders);
const std::list<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs);
void SearchHeadersForCppFile(const std::string& absFilename,
const std::list<std::string>& headerExtensions,
std::set<std::string>& absHeaders);
void ParseHeaders(const std::set<std::string>& absHeaders,
const std::map<std::string, std::string>& includedMocs,
std::map<std::string, std::string>& notIncludedMocs);