ENH: Replaced dependency integrity map with an explicit map from object file to source file for each language in each target. This simplifies creation of implicit dependency scanning rules and allows more than one object file in a target to start dependency scanning with the same source file.

This commit is contained in:
Brad King 2007-08-07 13:57:13 -04:00
parent 91384d7df4
commit d926792066
3 changed files with 63 additions and 47 deletions

View File

@ -1644,52 +1644,37 @@ void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf,
void cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3
::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &target) ::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &target)
{ {
// now write all the language stuff ImplicitDependLanguageMap const& implicitLangs =
// Set the set of files to check for dependency integrity. this->GetImplicitDepends(target);
std::set<cmStdString> checkSetLangs;
std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>&
checkSet = this->GetIntegrityCheckSet()[target.GetName()];
for(std::map<cmStdString,
cmLocalUnixMakefileGenerator3::IntegrityCheckSet>::const_iterator
l = checkSet.begin(); l != checkSet.end(); ++l)
{
checkSetLangs.insert(l->first);
}
// list the languages // list the languages
cmakefileStream cmakefileStream
<< "# The set of files whose dependency integrity should be checked:\n"; << "# The set of languages for which implicit dependencies are needed:\n";
cmakefileStream cmakefileStream
<< "SET(CMAKE_DEPENDS_LANGUAGES\n"; << "SET(CMAKE_DEPENDS_LANGUAGES\n";
for(std::set<cmStdString>::iterator for(ImplicitDependLanguageMap::const_iterator
l = checkSetLangs.begin(); l != checkSetLangs.end(); ++l) l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
{ {
cmakefileStream << " \"" << l->c_str() << "\"\n"; cmakefileStream << " \"" << l->first.c_str() << "\"\n";
} }
cmakefileStream << " )\n"; cmakefileStream << " )\n";
// now list the files for each language // now list the files for each language
for(std::set<cmStdString>::iterator cmakefileStream
l = checkSetLangs.begin(); l != checkSetLangs.end(); ++l) << "# The set of files for implicit dependencies of each language:\n";
for(ImplicitDependLanguageMap::const_iterator
l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
{ {
cmakefileStream cmakefileStream
<< "SET(CMAKE_DEPENDS_CHECK_" << l->c_str() << "\n"; << "SET(CMAKE_DEPENDS_CHECK_" << l->first.c_str() << "\n";
// get the check set for this local gen and language ImplicitDependFileMap const& implicitPairs = l->second;
cmLocalUnixMakefileGenerator3::IntegrityCheckSet iCheckSet =
checkSet[*l]; // for each file pair
// for each file for(ImplicitDependFileMap::const_iterator pi = implicitPairs.begin();
for(cmLocalUnixMakefileGenerator3::IntegrityCheckSet::const_iterator pi != implicitPairs.end(); ++pi)
csIter = iCheckSet.begin();
csIter != iCheckSet.end(); ++csIter)
{ {
cmakefileStream << " \"" << (*csIter)->GetFullPath() << "\"\n"; cmakefileStream << " \"" << pi->second << "\" ";
// Get the full path name of the object file. cmakefileStream << "\"" << pi->first << "\"\n";
std::string obj = this->Makefile->GetStartOutputDirectory();
obj += "/";
obj += this->GetObjectFileName(target, **csIter);
cmakefileStream << " \"" <<
this->Convert(obj.c_str(),
cmLocalGenerator::FULL).c_str() << "\"\n";
} }
cmakefileStream << " )\n"; cmakefileStream << " )\n";
} }
@ -1926,6 +1911,24 @@ cmLocalUnixMakefileGenerator3
return dir; return dir;
} }
//----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator3::ImplicitDependLanguageMap const&
cmLocalUnixMakefileGenerator3::GetImplicitDepends(cmTarget const& tgt)
{
return this->ImplicitDepends[tgt.GetName()];
}
//----------------------------------------------------------------------------
void
cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt,
const char* lang,
const char* obj,
const char* src)
{
this->ImplicitDepends[tgt.GetName()][lang][obj] = src;
}
//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3
::CreateCDCommand(std::vector<std::string>& commands, const char *tgtDir, ::CreateCDCommand(std::vector<std::string>& commands, const char *tgtDir,
const char *retDir) const char *retDir)

View File

@ -211,14 +211,17 @@ public:
std::string GetRelativeTargetDirectory(cmTarget& target); std::string GetRelativeTargetDirectory(cmTarget& target);
// List the files for which to check dependency integrity. Each // File pairs for implicit dependency scanning. The key of the map
// language has its own list because integrity may be checked // is the depender and the value is the explicit dependee.
// differently. struct ImplicitDependFileMap: public std::map<cmStdString, cmStdString> {};
struct IntegrityCheckSet: public std::set<cmSourceFile *> {}; struct ImplicitDependLanguageMap:
struct IntegrityCheckSetMap: public std::map<cmStdString, IntegrityCheckSet> public std::map<cmStdString, ImplicitDependFileMap> {};
{}; struct ImplicitDependTargetMap:
std::map<cmStdString, IntegrityCheckSetMap> &GetIntegrityCheckSet() public std::map<cmStdString, ImplicitDependLanguageMap> {};
{ return this->CheckDependFiles;} ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt);
void AddImplicitDepends(cmTarget const& tgt, const char* lang,
const char* obj, const char* src);
void AppendGlobalTargetDepends(std::vector<std::string>& depends, void AppendGlobalTargetDepends(std::vector<std::string>& depends,
cmTarget& target); cmTarget& target);
@ -324,7 +327,7 @@ private:
friend class cmMakefileUtilityTargetGenerator; friend class cmMakefileUtilityTargetGenerator;
friend class cmGlobalUnixMakefileGenerator3; friend class cmGlobalUnixMakefileGenerator3;
std::map<cmStdString, IntegrityCheckSetMap> CheckDependFiles; ImplicitDependTargetMap ImplicitDepends;
//========================================================================== //==========================================================================
// Configuration settings. // Configuration settings.

View File

@ -341,8 +341,18 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
this->WriteObjectBuildFile(obj, lang, source, depends); this->WriteObjectBuildFile(obj, lang, source, depends);
// The object file should be checked for dependency integrity. // The object file should be checked for dependency integrity.
std::string objFullPath = this->Makefile->GetCurrentOutputDirectory();
objFullPath += "/";
objFullPath += obj;
objFullPath =
this->Convert(objFullPath.c_str(), cmLocalGenerator::FULL);
std::string srcFullPath =
this->Convert(source.GetFullPath().c_str(), cmLocalGenerator::FULL);
this->LocalGenerator-> this->LocalGenerator->
CheckDependFiles[this->Target->GetName()][lang].insert(&source); AddImplicitDepends(*this->Target, lang,
objFullPath.c_str(),
srcFullPath.c_str());
// add this to the list of objects for this local generator // add this to the list of objects for this local generator
if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str())) if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str()))
{ {