cmGeneratorTarget: Inline GetSourceFiles from cmTarget.

This commit is contained in:
Stephen Kelly 2015-09-13 09:57:43 +02:00
parent 33f87bb1f5
commit 7b6dc0fe45
3 changed files with 49 additions and 49 deletions

View File

@ -842,7 +842,40 @@ static void AddInterfaceEntries(
void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files, void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const const std::string& config) const
{ {
this->Target->GetSourceFiles(files, config); // Lookup any existing link implementation for this configuration.
std::string key = cmSystemTools::UpperCase(config);
cmTarget::SourceFilesMapType& sfm = this->Target->GetSourceFilesMap();
if(!this->Target->GetLinkImplementationLanguageIsContextDependent())
{
files = sfm.begin()->second;
return;
}
cmTarget::SourceFilesMapType::iterator
it = sfm.find(key);
if(it != sfm.end())
{
files = it->second;
}
else
{
std::vector<std::string> srcs;
this->Target->GetSourceFiles(srcs, config);
std::set<cmSourceFile*> emitted;
for(std::vector<std::string>::const_iterator i = srcs.begin();
i != srcs.end(); ++i)
{
cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
if (emitted.insert(sf).second)
{
files.push_back(sf);
}
}
sfm[key] = files;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -101,9 +101,7 @@ public:
HeadToLinkImplementationMap> LinkImplMapType; HeadToLinkImplementationMap> LinkImplMapType;
LinkImplMapType LinkImplMap; LinkImplMapType LinkImplMap;
typedef std::map<std::string, std::vector<cmSourceFile*> > cmTarget::SourceFilesMapType SourceFilesMap;
SourceFilesMapType;
SourceFilesMapType SourceFilesMap;
std::set<cmLinkItem> UtilityItems; std::set<cmLinkItem> UtilityItems;
bool UtilityItemsDone; bool UtilityItemsDone;
@ -409,6 +407,11 @@ void cmTarget::Compute()
this->Internal->SourceItems, true); this->Internal->SourceItems, true);
} }
cmTarget::SourceFilesMapType& cmTarget::GetSourceFilesMap() const
{
return this->Internal->SourceFilesMap;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
{ {
@ -735,46 +738,6 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
cmDeleteAll(linkInterfaceSourcesEntries); cmDeleteAll(linkInterfaceSourcesEntries);
} }
//----------------------------------------------------------------------------
void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const
{
// Lookup any existing link implementation for this configuration.
std::string key = cmSystemTools::UpperCase(config);
if(!this->LinkImplementationLanguageIsContextDependent)
{
files = this->Internal->SourceFilesMap.begin()->second;
return;
}
cmTargetInternals::SourceFilesMapType::iterator
it = this->Internal->SourceFilesMap.find(key);
if(it != this->Internal->SourceFilesMap.end())
{
files = it->second;
}
else
{
std::vector<std::string> srcs;
this->GetSourceFiles(srcs, config);
std::set<cmSourceFile*> emitted;
for(std::vector<std::string>::const_iterator i = srcs.begin();
i != srcs.end(); ++i)
{
cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
if (emitted.insert(sf).second)
{
files.push_back(sf);
}
}
this->Internal->SourceFilesMap[key] = files;
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
{ {

View File

@ -135,11 +135,15 @@ public:
void Compute(); void Compute();
/** typedef std::map<std::string, std::vector<cmSourceFile*> >
* Get the list of the source files used by this target SourceFilesMapType;
*/
void GetSourceFiles(std::vector<cmSourceFile*> &files, SourceFilesMapType& GetSourceFilesMap() const;
const std::string& config) const;
bool GetLinkImplementationLanguageIsContextDependent() const {
return this->LinkImplementationLanguageIsContextDependent;
}
/** /**
* Add sources to the target. * Add sources to the target.
*/ */