From b24861d895f96040e35c94944cc3866e78e7781c Mon Sep 17 00:00:00 2001 From: Ian Scott Date: Mon, 30 Jul 2001 07:18:38 -0400 Subject: [PATCH] Removed the Uniquification of the include and link directory list in FinalPass, and achieved the same effect by makein m_LinkDirectores and m_IncludeDirectories a set rather than vector --- Source/cmCableClassSet.cxx | 4 +-- Source/cmCableWrapTclCommand.cxx | 4 +-- Source/cmDSPWriter.cxx | 8 ++--- Source/cmMakeDepend.cxx | 4 +-- Source/cmMakefile.cxx | 58 +++++++++++++++--------------- Source/cmMakefile.h | 16 ++++----- Source/cmUnixMakefileGenerator.cxx | 12 +++---- 7 files changed, 50 insertions(+), 56 deletions(-) diff --git a/Source/cmCableClassSet.cxx b/Source/cmCableClassSet.cxx index ed56ad626..54ebcfca8 100644 --- a/Source/cmCableClassSet.cxx +++ b/Source/cmCableClassSet.cxx @@ -644,11 +644,11 @@ void ElementCombinationGenerator::FindTagSource() } // Get the makefile's include path. - const std::vector& includePath = + const std::set& includePath = m_Makefile->GetIncludeDirectories(); // Search the path for a file called "(m_Tag).h". - for(std::vector::const_iterator dir = includePath.begin(); + for(std::set::const_iterator dir = includePath.begin(); dir != includePath.end(); ++dir) { std::string filePath = *dir; diff --git a/Source/cmCableWrapTclCommand.cxx b/Source/cmCableWrapTclCommand.cxx index feb24c800..1733a9b56 100644 --- a/Source/cmCableWrapTclCommand.cxx +++ b/Source/cmCableWrapTclCommand.cxx @@ -298,9 +298,9 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name, commandArgs += m_Makefile->GetStartDirectory(); commandArgs += "\""; - const std::vector& includes = + const std::set& includes = m_Makefile->GetIncludeDirectories(); - for(std::vector::const_iterator i = includes.begin(); + for(std::set::const_iterator i = includes.begin(); i != includes.end(); ++i) { commandArgs += " -I"; diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index eff7bf15b..626a213f3 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -68,8 +68,8 @@ void cmDSPWriter::OutputDSPFile() } // Setup /I and /LIBPATH options for the resulting DSP file - std::vector& includes = m_Makefile->GetIncludeDirectories(); - std::vector::iterator i; + std::set& includes = m_Makefile->GetIncludeDirectories(); + std::set::iterator i; for(i = includes.begin(); i != includes.end(); ++i) { m_IncludeOptions += "/I \""; @@ -504,8 +504,8 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName, libMultiLineOptions += exePath; libMultiLineOptions += "\" \n"; } - std::vector::iterator i; - std::vector& libdirs = m_Makefile->GetLinkDirectories(); + std::set::iterator i; + std::set& libdirs = m_Makefile->GetLinkDirectories(); for(i = libdirs.begin(); i != libdirs.end(); ++i) { libOptions += " /LIBPATH:\""; diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 5a18e072f..6416b9872 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -90,9 +90,9 @@ void cmMakeDepend::SetMakefile(const cmMakefile* makefile) m_Makefile->m_ComplainFileRegularExpression.c_str()); // Now extract any include paths from the makefile flags - const std::vector& includes = + const std::set& includes = m_Makefile->GetIncludeDirectories(); - for(std::vector::const_iterator j = includes.begin(); + for(std::set::const_iterator j = includes.begin(); j != includes.end(); ++j) { std::string path = *j; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a420d2e73..915eb23b7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -170,6 +170,17 @@ void cmMakefile::PrintStringVector(const char* s, const std::vector std::cout << " )\n"; } +void cmMakefile::PrintStringVector(const char* s, const std::set& v) const +{ + std::cout << s << ": ( \n"; + for(std::set::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 void cmMakefile::Print() const @@ -409,8 +420,6 @@ void cmMakefile::FinalPass() // do all the variable expansions here this->ExpandVariables(); - this->StripDuplicateDirectories(); - // give all the commands a chance to do something // after the file has been parsed before generation for(std::vector::iterator i = m_UsedCommands.begin(); @@ -536,7 +545,7 @@ void cmMakefile::AddLinkLibrary(const char* lib) void cmMakefile::AddLinkDirectory(const char* dir) { - m_LinkDirectories.push_back(dir); + m_LinkDirectories.insert(dir); } void cmMakefile::AddSubDirectory(const char* sub) @@ -546,7 +555,7 @@ void cmMakefile::AddSubDirectory(const char* sub) void cmMakefile::AddIncludeDirectory(const char* inc) { - m_IncludeDirectories.push_back(inc); + m_IncludeDirectories.insert(inc); } void cmMakefile::AddDefinition(const char* name, const char* value) @@ -730,19 +739,31 @@ std::string cmMakefile::GetParentListFileName(const char *currentFileName) void cmMakefile::ExpandVariables() { // Now expand varibles in the include and link strings - std::vector::iterator j, begin, end; + std::set::iterator j, begin, end; begin = m_IncludeDirectories.begin(); end = m_IncludeDirectories.end(); + std::set new_set; + std::string x; + for(j = begin; j != end; ++j) { - this->ExpandVariablesInString(*j); + x= *j; + this->ExpandVariablesInString(x); + new_set.insert(x); } + m_IncludeDirectories = new_set; + + new_set.clear(); begin = m_LinkDirectories.begin(); end = m_LinkDirectories.end(); for(j = begin; j != end; ++j) { - this->ExpandVariablesInString(*j); + x = *j; + this->ExpandVariablesInString(x); + new_set.insert(x); } + m_LinkDirectories = new_set; + cmTarget::LinkLibraries::iterator j2, end2; j2 = m_LinkLibraries.begin(); end2 = m_LinkLibraries.end(); @@ -793,29 +814,6 @@ int cmMakefile::DumpDocumentationToFile(const char *fileName) } - // Remove duplicate directories from the library and include paths. -void cmMakefile::StripDuplicateDirectories() -{ - std::vector::iterator begin, end; - // remove duplicates from m_IncludeDirectories - begin = m_IncludeDirectories.begin(); - end = m_IncludeDirectories.end(); - std::list tmp1(begin, end); - tmp1.sort(); - m_IncludeDirectories.clear(); - std::unique_copy(tmp1.begin(), tmp1.end(), std::back_inserter(m_IncludeDirectories)); - - // remove duplicates from m_LinkDirectories - begin = m_LinkDirectories.begin(); - end = m_LinkDirectories.end(); - std::list tmp2(begin, end); - tmp2.sort(); - m_LinkDirectories.clear(); - std::unique_copy(tmp2.begin(), tmp2.end(), std::back_inserter(m_LinkDirectories)); -} - - - void cmMakefile::ExpandVariablesInString(std::string& source) const { this->ExpandVariablesInString(source, false); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e44d73d92..db7caf1ee 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -383,11 +383,11 @@ public: /** * Get a list of include directories in the build. */ - std::vector& GetIncludeDirectories() + std::set& GetIncludeDirectories() { return m_IncludeDirectories; } - const std::vector& GetIncludeDirectories() const + const std::set& GetIncludeDirectories() const { return m_IncludeDirectories; } @@ -395,7 +395,7 @@ public: /** * Get a list of link directories in the build. */ - std::vector& GetLinkDirectories() + std::set& GetLinkDirectories() { return m_LinkDirectories; } @@ -481,11 +481,6 @@ public: */ void ExpandVariables(); - /** - * Strip Duplicate directories from Library and Include paths - */ - void cmMakefile::StripDuplicateDirectories(); - /** Recursivly read and create a cmMakefile object for * all CMakeLists.txt files in the GetSubDirectories list. * Once the file is found, it ReadListFile is called on @@ -528,8 +523,8 @@ protected: SourceMap m_Sources; std::vector m_SubDirectories; // list of sub directories - std::vector m_IncludeDirectories; - std::vector m_LinkDirectories; + std::set m_IncludeDirectories; + std::set m_LinkDirectories; std::vector m_ListFiles; // list of command files loaded @@ -560,6 +555,7 @@ private: friend class cmMakeDepend; // make depend needs direct access // to the m_Sources array void PrintStringVector(const char* s, const std::vector& v) const; + void PrintStringVector(const char* s, const std::set& v) const; void AddDefaultCommands(); void AddDefaultDefinitions(); std::set m_FunctionBlockers; diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 5a93a3817..2599068f5 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -65,7 +65,7 @@ void cmUnixMakefileGenerator::GenerateMakefile() m_LibraryOutputPath += "/"; } cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str()); - m_Makefile->GetLinkDirectories().push_back(m_LibraryOutputPath); + m_Makefile->GetLinkDirectories().insert(m_LibraryOutputPath); } if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) { @@ -76,7 +76,7 @@ void cmUnixMakefileGenerator::GenerateMakefile() m_ExecutableOutputPath += "/"; } cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str()); - m_Makefile->GetLinkDirectories().push_back(m_ExecutableOutputPath); + m_Makefile->GetLinkDirectories().insert(m_ExecutableOutputPath); } if(m_CacheOnly) @@ -362,8 +362,8 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, // collect all the flags needed for linking libraries std::string linkLibs; - std::vector& libdirs = m_Makefile->GetLinkDirectories(); - for(std::vector::iterator libDir = libdirs.begin(); + std::set& libdirs = m_Makefile->GetLinkDirectories(); + for(std::set::iterator libDir = libdirs.begin(); libDir != libdirs.end(); ++libDir) { std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str()); @@ -653,8 +653,8 @@ void cmUnixMakefileGenerator::OutputMakeFlags(std::ostream& fout) { // Output Include paths fout << "INCLUDE_FLAGS = "; - std::vector& includes = m_Makefile->GetIncludeDirectories(); - std::vector::iterator i; + std::set& includes = m_Makefile->GetIncludeDirectories(); + std::set::iterator i; fout << "-I" << m_Makefile->GetStartDirectory() << " "; for(i = includes.begin(); i != includes.end(); ++i) {