From 2f42d7ffcb541979059715c6373f1d6f12044f5a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 27 Apr 2001 14:51:43 -0400 Subject: [PATCH] BUG: Removed output of dual rules for source files that are processed by both the compiler and by a custom command. Also removed generation of duplicate CMakeLists.txt in the project files. --- Source/cmDSPMakefile.cxx | 37 +++++++++++-------------------------- Source/cmDSPMakefile.h | 1 - Source/cmDSPWriter.cxx | 37 +++++++++++-------------------------- Source/cmDSPWriter.h | 1 - Source/cmSourceGroup.cxx | 26 ++++++++++++++++++++------ Source/cmSourceGroup.h | 22 ++++++++-------------- 6 files changed, 50 insertions(+), 74 deletions(-) diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx index c107bb4e7..5b4073c28 100644 --- a/Source/cmDSPMakefile.cxx +++ b/Source/cmDSPMakefile.cxx @@ -239,10 +239,9 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, for(std::vector::const_iterator sg = sourceGroups.begin(); sg != sourceGroups.end(); ++sg) { - const std::vector& sources = sg->GetSources(); - const cmSourceGroup::CustomCommands& customCommands = sg->GetCustomCommands(); + const cmSourceGroup::BuildRules& buildRules = sg->GetBuildRules(); // If the group is empty, don't write it at all. - if(sources.empty() && customCommands.empty()) + if(buildRules.empty()) { continue; } // If the group has a name, write the header. @@ -252,24 +251,21 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, this->WriteDSPBeginGroup(fout, name.c_str(), ""); } - // Loop through each source in the source group. - for(std::vector::const_iterator s = sources.begin(); - s != sources.end(); ++s) - { - this->WriteDSPBuildRule(fout, s->c_str()); - } - - // Loop through each custom command in the source group. - for(cmSourceGroup::CustomCommands::const_iterator cc = - customCommands.begin(); cc != customCommands.end(); ++ cc) + // Loop through each build rule in the source group. + for(cmSourceGroup::BuildRules::const_iterator cc = + buildRules.begin(); cc != buildRules.end(); ++ cc) { std::string source = cc->first; const cmSourceGroup::Commands& commands = cc->second; - fout << "# Begin Source File\n\n"; + fout << "# Begin Source File\n\n";\ + + // Tell MS-Dev what the source is. If the compiler knows how to + // build it, then it will. fout << "SOURCE=" << source << "\n\n"; - // Loop through every command generating code from the current source. + // Loop through every custom command generating code from the + // current source. for(cmSourceGroup::Commands::const_iterator c = commands.begin(); c != commands.end(); ++c) { @@ -493,14 +489,3 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout) fout << buffer << std::endl; } } - - -void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout, const char* path) -{ - fout << "# Begin Source File\n\n"; - fout << "SOURCE=" - << path << "\n"; - fout << "# End Source File\n"; -} - - diff --git a/Source/cmDSPMakefile.h b/Source/cmDSPMakefile.h index fe67aa23e..6082f1e28 100644 --- a/Source/cmDSPMakefile.h +++ b/Source/cmDSPMakefile.h @@ -101,7 +101,6 @@ private: void WriteDSPEndGroup(std::ostream& fout); void WriteDSPHeader(std::ostream& fout, const char *libName, const cmTarget &tgt); - void WriteDSPBuildRule(std::ostream& fout, const char*); void WriteDSPBuildRule(std::ostream& fout); void WriteDSPFooter(std::ostream& fout); void AddDSPBuildRule(cmSourceGroup&); diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index c107bb4e7..5b4073c28 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -239,10 +239,9 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, for(std::vector::const_iterator sg = sourceGroups.begin(); sg != sourceGroups.end(); ++sg) { - const std::vector& sources = sg->GetSources(); - const cmSourceGroup::CustomCommands& customCommands = sg->GetCustomCommands(); + const cmSourceGroup::BuildRules& buildRules = sg->GetBuildRules(); // If the group is empty, don't write it at all. - if(sources.empty() && customCommands.empty()) + if(buildRules.empty()) { continue; } // If the group has a name, write the header. @@ -252,24 +251,21 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, this->WriteDSPBeginGroup(fout, name.c_str(), ""); } - // Loop through each source in the source group. - for(std::vector::const_iterator s = sources.begin(); - s != sources.end(); ++s) - { - this->WriteDSPBuildRule(fout, s->c_str()); - } - - // Loop through each custom command in the source group. - for(cmSourceGroup::CustomCommands::const_iterator cc = - customCommands.begin(); cc != customCommands.end(); ++ cc) + // Loop through each build rule in the source group. + for(cmSourceGroup::BuildRules::const_iterator cc = + buildRules.begin(); cc != buildRules.end(); ++ cc) { std::string source = cc->first; const cmSourceGroup::Commands& commands = cc->second; - fout << "# Begin Source File\n\n"; + fout << "# Begin Source File\n\n";\ + + // Tell MS-Dev what the source is. If the compiler knows how to + // build it, then it will. fout << "SOURCE=" << source << "\n\n"; - // Loop through every command generating code from the current source. + // Loop through every custom command generating code from the + // current source. for(cmSourceGroup::Commands::const_iterator c = commands.begin(); c != commands.end(); ++c) { @@ -493,14 +489,3 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout) fout << buffer << std::endl; } } - - -void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout, const char* path) -{ - fout << "# Begin Source File\n\n"; - fout << "SOURCE=" - << path << "\n"; - fout << "# End Source File\n"; -} - - diff --git a/Source/cmDSPWriter.h b/Source/cmDSPWriter.h index fe67aa23e..6082f1e28 100644 --- a/Source/cmDSPWriter.h +++ b/Source/cmDSPWriter.h @@ -101,7 +101,6 @@ private: void WriteDSPEndGroup(std::ostream& fout); void WriteDSPHeader(std::ostream& fout, const char *libName, const cmTarget &tgt); - void WriteDSPBuildRule(std::ostream& fout, const char*); void WriteDSPBuildRule(std::ostream& fout); void WriteDSPFooter(std::ostream& fout); void AddDSPBuildRule(cmSourceGroup&); diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 24d56ab7a..49b2bd79b 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -57,8 +57,7 @@ cmSourceGroup::cmSourceGroup(const char* name, const char* regex): cmSourceGroup::cmSourceGroup(const cmSourceGroup& r): m_Name(r.m_Name), m_GroupRegex(r.m_GroupRegex), - m_Sources(r.m_Sources), - m_CustomCommands(r.m_CustomCommands) + m_BuildRules(r.m_BuildRules) { } @@ -72,6 +71,21 @@ bool cmSourceGroup::Matches(const char* name) } +/** + * Add a source to the group that the compiler will know how to build. + */ +void cmSourceGroup::AddSource(const char* name) +{ + BuildRules::iterator s = m_BuildRules.find(name); + if(s == m_BuildRules.end()) + { + // The source was not found. Add it with no commands. + m_BuildRules[name]; + return; + } +} + + /** * Add a source and corresponding custom command to the group. If the * source already exists, the command will be added to its set of commands. @@ -80,13 +94,13 @@ bool cmSourceGroup::Matches(const char* name) */ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd) { - CustomCommands::iterator s = m_CustomCommands.find(cmd.GetSourceName()); - if(s == m_CustomCommands.end()) + BuildRules::iterator s = m_BuildRules.find(cmd.GetSourceName()); + if(s == m_BuildRules.end()) { // The source was not found. Add it with this command. - m_CustomCommands[cmd.GetSourceName()][cmd.GetCommand()]. + m_BuildRules[cmd.GetSourceName()][cmd.GetCommand()]. m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end()); - m_CustomCommands[cmd.GetSourceName()][cmd.GetCommand()]. + m_BuildRules[cmd.GetSourceName()][cmd.GetCommand()]. m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end()); return; } diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index db79ecc12..9162f2ba8 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -77,20 +77,17 @@ public: /** * Map from source to command map. */ - typedef std::map CustomCommands; + typedef std::map BuildRules; bool Matches(const char* name); void SetGroupRegex(const char* regex) { m_GroupRegex.compile(regex); } - void AddSource(const char* name) - { m_Sources.push_back(name); } + void AddSource(const char* name); void AddCustomCommand(const cmCustomCommand &cmd); const char* GetName() const { return m_Name.c_str(); } - const std::vector& GetSources() const - { return m_Sources; } - const CustomCommands& GetCustomCommands() const - { return m_CustomCommands; } + const BuildRules& GetBuildRules() const + { return m_BuildRules; } private: /** @@ -104,14 +101,11 @@ private: cmRegularExpression m_GroupRegex; /** - * The sources in this group that the compiler will know how to build. + * Map from source name to the commands to build from the source. + * Some commands may build from files that the compiler also knows how to + * build. */ - std::vector m_Sources; - - /** - * The custom commands in this group and their corresponding sources. - */ - CustomCommands m_CustomCommands; + BuildRules m_BuildRules; }; #endif