ENH: only check for the existance of a header file if:

-the original file is a C/C++ implementation file
-the header file is not already part of the sources

Alex
This commit is contained in:
Alexander Neundorf 2009-03-10 17:34:18 -04:00
parent 32258b44bc
commit 5700deb16a
1 changed files with 55 additions and 11 deletions

View File

@ -230,7 +230,10 @@ void cmExtraCodeBlocksGenerator
// Collect all used source files in the project
std::map<std::string, std::string> sourceFiles;
// Sort them into two containers, one for C/C++ implementation files
// which may have an acompanying header, one for all other files
std::map<std::string, cmSourceFile*> cFiles;
std::set<std::string> otherFiles;
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
lg!=lgs.end(); lg++)
{
@ -250,7 +253,32 @@ void cmExtraCodeBlocksGenerator
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++)
{
sourceFiles[(*si)->GetFullPath()] = ti->first;
// check whether it is a C/C++ implementation file
bool isCFile = false;
if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
{
for(std::vector<std::string>::const_iterator
ext = mf->GetSourceExtensions().begin();
ext != mf->GetSourceExtensions().end();
++ext)
{
if ((*si)->GetExtension() == *ext)
{
isCFile = true;
break;
}
}
}
// then put it accordingly into one of the two containers
if (isCFile)
{
cFiles[(*si)->GetFullPath()] = *si ;
}
else
{
otherFiles.insert((*si)->GetFullPath());
}
}
}
default: // intended fallthrough
@ -265,9 +293,9 @@ void cmExtraCodeBlocksGenerator
// file exists. If it does, it is inserted into the map of files.
// A very similar version of that code exists also in the kdevelop
// project generator.
for (std::map<std::string, std::string>::const_iterator
sit=sourceFiles.begin();
sit!=sourceFiles.end();
for (std::map<std::string, cmSourceFile*>::const_iterator
sit=cFiles.begin();
sit!=cFiles.end();
++sit)
{
std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first);
@ -283,21 +311,37 @@ void cmExtraCodeBlocksGenerator
std::string hname=headerBasename;
hname += ".";
hname += *ext;
// if it's already in the set, don't check if it exists on disk
std::set<std::string>::const_iterator headerIt=otherFiles.find(hname);
if (headerIt != otherFiles.end())
{
break;
}
if(cmSystemTools::FileExists(hname.c_str()))
{
sourceFiles[hname] = hname;
otherFiles.insert(hname);
break;
}
}
}
// insert all used source files in the CodeBlocks project
for (std::map<std::string, std::string>::const_iterator
sit=sourceFiles.begin();
sit!=sourceFiles.end();
// insert all source files in the CodeBlocks project
// first the C/C++ implementation files, then all others
for (std::map<std::string, cmSourceFile*>::const_iterator
sit=cFiles.begin();
sit!=cFiles.end();
++sit)
{
fout<<" <Unit filename=\""<<sit->first <<"\">\n"
fout<<" <Unit filename=\""<< sit->first <<"\">\n"
" </Unit>\n";
}
for (std::set<std::string>::const_iterator
sit=otherFiles.begin();
sit!=otherFiles.end();
++sit)
{
fout<<" <Unit filename=\""<< sit->c_str() <<"\">\n"
" </Unit>\n";
}