BUG: Changed include and link directory paths in cmMakefile back to std::vector because there is an order dependency. Only cmMakefile::AddIncludeDirectory and cmMakefile::AddLinkDirectory should be called to add directories to the paths. They make sure the paths are unique as they are inserted.

This commit is contained in:
Brad King 2001-07-30 11:34:03 -04:00
parent b24861d895
commit ddec29c52d
7 changed files with 52 additions and 61 deletions

View File

@ -644,11 +644,11 @@ void ElementCombinationGenerator::FindTagSource()
} }
// Get the makefile's include path. // Get the makefile's include path.
const std::set<std::string>& includePath = const std::vector<std::string>& includePath =
m_Makefile->GetIncludeDirectories(); m_Makefile->GetIncludeDirectories();
// Search the path for a file called "(m_Tag).h". // Search the path for a file called "(m_Tag).h".
for(std::set<std::string>::const_iterator dir = includePath.begin(); for(std::vector<std::string>::const_iterator dir = includePath.begin();
dir != includePath.end(); ++dir) dir != includePath.end(); ++dir)
{ {
std::string filePath = *dir; std::string filePath = *dir;

View File

@ -298,9 +298,9 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name,
commandArgs += m_Makefile->GetStartDirectory(); commandArgs += m_Makefile->GetStartDirectory();
commandArgs += "\""; commandArgs += "\"";
const std::set<std::string>& includes = const std::vector<std::string>& includes =
m_Makefile->GetIncludeDirectories(); m_Makefile->GetIncludeDirectories();
for(std::set<std::string>::const_iterator i = includes.begin(); for(std::vector<std::string>::const_iterator i = includes.begin();
i != includes.end(); ++i) i != includes.end(); ++i)
{ {
commandArgs += " -I"; commandArgs += " -I";

View File

@ -68,8 +68,8 @@ void cmDSPWriter::OutputDSPFile()
} }
// Setup /I and /LIBPATH options for the resulting DSP file // Setup /I and /LIBPATH options for the resulting DSP file
std::set<std::string>& includes = m_Makefile->GetIncludeDirectories(); std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::set<std::string>::iterator i; std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i) for(i = includes.begin(); i != includes.end(); ++i)
{ {
m_IncludeOptions += "/I \""; m_IncludeOptions += "/I \"";
@ -504,8 +504,8 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
libMultiLineOptions += exePath; libMultiLineOptions += exePath;
libMultiLineOptions += "\" \n"; libMultiLineOptions += "\" \n";
} }
std::set<std::string>::iterator i; std::vector<std::string>::iterator i;
std::set<std::string>& libdirs = m_Makefile->GetLinkDirectories(); std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(i = libdirs.begin(); i != libdirs.end(); ++i) for(i = libdirs.begin(); i != libdirs.end(); ++i)
{ {
libOptions += " /LIBPATH:\""; libOptions += " /LIBPATH:\"";

View File

@ -90,9 +90,9 @@ void cmMakeDepend::SetMakefile(const cmMakefile* makefile)
m_Makefile->m_ComplainFileRegularExpression.c_str()); m_Makefile->m_ComplainFileRegularExpression.c_str());
// Now extract any include paths from the makefile flags // Now extract any include paths from the makefile flags
const std::set<std::string>& includes = const std::vector<std::string>& includes =
m_Makefile->GetIncludeDirectories(); m_Makefile->GetIncludeDirectories();
for(std::set<std::string>::const_iterator j = includes.begin(); for(std::vector<std::string>::const_iterator j = includes.begin();
j != includes.end(); ++j) j != includes.end(); ++j)
{ {
std::string path = *j; std::string path = *j;

View File

@ -170,17 +170,6 @@ void cmMakefile::PrintStringVector(const char* s, const std::vector<std::string>
std::cout << " )\n"; std::cout << " )\n";
} }
void cmMakefile::PrintStringVector(const char* s, const std::set<std::string>& v) const
{
std::cout << s << ": ( \n";
for(std::set<std::string>::const_iterator i = v.begin();
i != v.end(); ++i)
{
std::cout << (*i).c_str() << " ";
}
std::cout << " )\n";
}
// call print on all the classes in the makefile // call print on all the classes in the makefile
void cmMakefile::Print() const void cmMakefile::Print() const
@ -545,7 +534,15 @@ void cmMakefile::AddLinkLibrary(const char* lib)
void cmMakefile::AddLinkDirectory(const char* dir) void cmMakefile::AddLinkDirectory(const char* dir)
{ {
m_LinkDirectories.insert(dir); // Don't add a link directory that is already present. Yes, this
// linear search results in n^2 behavior, but n won't be getting
// much bigger than 20. We cannot use a set because of order
// dependency of the link search path.
if(std::find(m_LinkDirectories.begin(),
m_LinkDirectories.end(), dir) == m_LinkDirectories.end())
{
m_LinkDirectories.push_back(dir);
}
} }
void cmMakefile::AddSubDirectory(const char* sub) void cmMakefile::AddSubDirectory(const char* sub)
@ -555,7 +552,15 @@ void cmMakefile::AddSubDirectory(const char* sub)
void cmMakefile::AddIncludeDirectory(const char* inc) void cmMakefile::AddIncludeDirectory(const char* inc)
{ {
m_IncludeDirectories.insert(inc); // Don't add an include directory that is already present. Yes,
// this linear search results in n^2 behavior, but n won't be
// getting much bigger than 20. We cannot use a set because of
// order dependency of the include path.
if(std::find(m_IncludeDirectories.begin(),
m_IncludeDirectories.end(), inc) == m_IncludeDirectories.end())
{
m_IncludeDirectories.push_back(inc);
}
} }
void cmMakefile::AddDefinition(const char* name, const char* value) void cmMakefile::AddDefinition(const char* name, const char* value)
@ -739,37 +744,20 @@ std::string cmMakefile::GetParentListFileName(const char *currentFileName)
void cmMakefile::ExpandVariables() void cmMakefile::ExpandVariables()
{ {
// Now expand varibles in the include and link strings // Now expand varibles in the include and link strings
std::set<std::string>::iterator j, begin, end; for(std::vector<std::string>::iterator d = m_IncludeDirectories.begin();
begin = m_IncludeDirectories.begin(); d != m_IncludeDirectories.end(); ++d)
end = m_IncludeDirectories.end();
std::set<std::string> new_set;
std::string x;
for(j = begin; j != end; ++j)
{ {
x= *j; this->ExpandVariablesInString(*d);
this->ExpandVariablesInString(x);
new_set.insert(x);
} }
m_IncludeDirectories = new_set; for(std::vector<std::string>::iterator d = m_LinkDirectories.begin();
d != m_LinkDirectories.end(); ++d)
new_set.clear();
begin = m_LinkDirectories.begin();
end = m_LinkDirectories.end();
for(j = begin; j != end; ++j)
{ {
x = *j; this->ExpandVariablesInString(*d);
this->ExpandVariablesInString(x);
new_set.insert(x);
} }
m_LinkDirectories = new_set; for(cmTarget::LinkLibraries::iterator l = m_LinkLibraries.begin();
l != m_LinkLibraries.end(); ++l)
cmTarget::LinkLibraries::iterator j2, end2;
j2 = m_LinkLibraries.begin();
end2 = m_LinkLibraries.end();
for(; j2 != end2; ++j2)
{ {
this->ExpandVariablesInString(j2->first); this->ExpandVariablesInString(l->first);
} }
} }

View File

@ -383,11 +383,11 @@ public:
/** /**
* Get a list of include directories in the build. * Get a list of include directories in the build.
*/ */
std::set<std::string>& GetIncludeDirectories() std::vector<std::string>& GetIncludeDirectories()
{ {
return m_IncludeDirectories; return m_IncludeDirectories;
} }
const std::set<std::string>& GetIncludeDirectories() const const std::vector<std::string>& GetIncludeDirectories() const
{ {
return m_IncludeDirectories; return m_IncludeDirectories;
} }
@ -395,7 +395,7 @@ public:
/** /**
* Get a list of link directories in the build. * Get a list of link directories in the build.
*/ */
std::set<std::string>& GetLinkDirectories() std::vector<std::string>& GetLinkDirectories()
{ {
return m_LinkDirectories; return m_LinkDirectories;
} }
@ -523,8 +523,12 @@ protected:
SourceMap m_Sources; SourceMap m_Sources;
std::vector<std::string> m_SubDirectories; // list of sub directories std::vector<std::string> m_SubDirectories; // list of sub directories
std::set<std::string> m_IncludeDirectories;
std::set<std::string> m_LinkDirectories; // The include and link-library paths. These may have order
// dependency, so they must be vectors (not set).
std::vector<std::string> m_IncludeDirectories;
std::vector<std::string> m_LinkDirectories;
std::vector<std::string> m_ListFiles; // list of command files loaded std::vector<std::string> m_ListFiles; // list of command files loaded
@ -555,7 +559,6 @@ private:
friend class cmMakeDepend; // make depend needs direct access friend class cmMakeDepend; // make depend needs direct access
// to the m_Sources array // to the m_Sources array
void PrintStringVector(const char* s, const std::vector<std::string>& v) const; void PrintStringVector(const char* s, const std::vector<std::string>& v) const;
void PrintStringVector(const char* s, const std::set<std::string>& v) const;
void AddDefaultCommands(); void AddDefaultCommands();
void AddDefaultDefinitions(); void AddDefaultDefinitions();
std::set<cmFunctionBlocker *> m_FunctionBlockers; std::set<cmFunctionBlocker *> m_FunctionBlockers;

View File

@ -65,7 +65,7 @@ void cmUnixMakefileGenerator::GenerateMakefile()
m_LibraryOutputPath += "/"; m_LibraryOutputPath += "/";
} }
cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str()); cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str());
m_Makefile->GetLinkDirectories().insert(m_LibraryOutputPath); m_Makefile->AddLinkDirectory(m_LibraryOutputPath.c_str());
} }
if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
{ {
@ -76,7 +76,7 @@ void cmUnixMakefileGenerator::GenerateMakefile()
m_ExecutableOutputPath += "/"; m_ExecutableOutputPath += "/";
} }
cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str()); cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str());
m_Makefile->GetLinkDirectories().insert(m_ExecutableOutputPath); m_Makefile->AddLinkDirectory(m_ExecutableOutputPath.c_str());
} }
if(m_CacheOnly) if(m_CacheOnly)
@ -362,8 +362,8 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
// collect all the flags needed for linking libraries // collect all the flags needed for linking libraries
std::string linkLibs; std::string linkLibs;
std::set<std::string>& libdirs = m_Makefile->GetLinkDirectories(); std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(std::set<std::string>::iterator libDir = libdirs.begin(); for(std::vector<std::string>::iterator libDir = libdirs.begin();
libDir != libdirs.end(); ++libDir) libDir != libdirs.end(); ++libDir)
{ {
std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str()); std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str());
@ -653,8 +653,8 @@ void cmUnixMakefileGenerator::OutputMakeFlags(std::ostream& fout)
{ {
// Output Include paths // Output Include paths
fout << "INCLUDE_FLAGS = "; fout << "INCLUDE_FLAGS = ";
std::set<std::string>& includes = m_Makefile->GetIncludeDirectories(); std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::set<std::string>::iterator i; std::vector<std::string>::iterator i;
fout << "-I" << m_Makefile->GetStartDirectory() << " "; fout << "-I" << m_Makefile->GetStartDirectory() << " ";
for(i = includes.begin(); i != includes.end(); ++i) for(i = includes.begin(); i != includes.end(); ++i)
{ {