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.

This commit is contained in:
Brad King 2001-04-27 14:51:43 -04:00
parent 9020fec9a9
commit 2f42d7ffcb
6 changed files with 50 additions and 74 deletions

View File

@ -239,10 +239,9 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin(); for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
sg != sourceGroups.end(); ++sg) sg != sourceGroups.end(); ++sg)
{ {
const std::vector<std::string>& sources = sg->GetSources(); const cmSourceGroup::BuildRules& buildRules = sg->GetBuildRules();
const cmSourceGroup::CustomCommands& customCommands = sg->GetCustomCommands();
// If the group is empty, don't write it at all. // If the group is empty, don't write it at all.
if(sources.empty() && customCommands.empty()) if(buildRules.empty())
{ continue; } { continue; }
// If the group has a name, write the header. // 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(), ""); this->WriteDSPBeginGroup(fout, name.c_str(), "");
} }
// Loop through each source in the source group. // Loop through each build rule in the source group.
for(std::vector<std::string>::const_iterator s = sources.begin(); for(cmSourceGroup::BuildRules::const_iterator cc =
s != sources.end(); ++s) buildRules.begin(); cc != buildRules.end(); ++ cc)
{
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)
{ {
std::string source = cc->first; std::string source = cc->first;
const cmSourceGroup::Commands& commands = cc->second; 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"; 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(); for(cmSourceGroup::Commands::const_iterator c = commands.begin();
c != commands.end(); ++c) c != commands.end(); ++c)
{ {
@ -493,14 +489,3 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout)
fout << buffer << std::endl; 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";
}

View File

@ -101,7 +101,6 @@ private:
void WriteDSPEndGroup(std::ostream& fout); void WriteDSPEndGroup(std::ostream& fout);
void WriteDSPHeader(std::ostream& fout, const char *libName, void WriteDSPHeader(std::ostream& fout, const char *libName,
const cmTarget &tgt); const cmTarget &tgt);
void WriteDSPBuildRule(std::ostream& fout, const char*);
void WriteDSPBuildRule(std::ostream& fout); void WriteDSPBuildRule(std::ostream& fout);
void WriteDSPFooter(std::ostream& fout); void WriteDSPFooter(std::ostream& fout);
void AddDSPBuildRule(cmSourceGroup&); void AddDSPBuildRule(cmSourceGroup&);

View File

@ -239,10 +239,9 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin(); for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
sg != sourceGroups.end(); ++sg) sg != sourceGroups.end(); ++sg)
{ {
const std::vector<std::string>& sources = sg->GetSources(); const cmSourceGroup::BuildRules& buildRules = sg->GetBuildRules();
const cmSourceGroup::CustomCommands& customCommands = sg->GetCustomCommands();
// If the group is empty, don't write it at all. // If the group is empty, don't write it at all.
if(sources.empty() && customCommands.empty()) if(buildRules.empty())
{ continue; } { continue; }
// If the group has a name, write the header. // 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(), ""); this->WriteDSPBeginGroup(fout, name.c_str(), "");
} }
// Loop through each source in the source group. // Loop through each build rule in the source group.
for(std::vector<std::string>::const_iterator s = sources.begin(); for(cmSourceGroup::BuildRules::const_iterator cc =
s != sources.end(); ++s) buildRules.begin(); cc != buildRules.end(); ++ cc)
{
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)
{ {
std::string source = cc->first; std::string source = cc->first;
const cmSourceGroup::Commands& commands = cc->second; 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"; 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(); for(cmSourceGroup::Commands::const_iterator c = commands.begin();
c != commands.end(); ++c) c != commands.end(); ++c)
{ {
@ -493,14 +489,3 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout)
fout << buffer << std::endl; 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";
}

View File

@ -101,7 +101,6 @@ private:
void WriteDSPEndGroup(std::ostream& fout); void WriteDSPEndGroup(std::ostream& fout);
void WriteDSPHeader(std::ostream& fout, const char *libName, void WriteDSPHeader(std::ostream& fout, const char *libName,
const cmTarget &tgt); const cmTarget &tgt);
void WriteDSPBuildRule(std::ostream& fout, const char*);
void WriteDSPBuildRule(std::ostream& fout); void WriteDSPBuildRule(std::ostream& fout);
void WriteDSPFooter(std::ostream& fout); void WriteDSPFooter(std::ostream& fout);
void AddDSPBuildRule(cmSourceGroup&); void AddDSPBuildRule(cmSourceGroup&);

View File

@ -57,8 +57,7 @@ cmSourceGroup::cmSourceGroup(const char* name, const char* regex):
cmSourceGroup::cmSourceGroup(const cmSourceGroup& r): cmSourceGroup::cmSourceGroup(const cmSourceGroup& r):
m_Name(r.m_Name), m_Name(r.m_Name),
m_GroupRegex(r.m_GroupRegex), m_GroupRegex(r.m_GroupRegex),
m_Sources(r.m_Sources), m_BuildRules(r.m_BuildRules)
m_CustomCommands(r.m_CustomCommands)
{ {
} }
@ -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 * 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. * 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) void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
{ {
CustomCommands::iterator s = m_CustomCommands.find(cmd.GetSourceName()); BuildRules::iterator s = m_BuildRules.find(cmd.GetSourceName());
if(s == m_CustomCommands.end()) if(s == m_BuildRules.end())
{ {
// The source was not found. Add it with this command. // 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_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()); m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end());
return; return;
} }

View File

@ -77,20 +77,17 @@ public:
/** /**
* Map from source to command map. * Map from source to command map.
*/ */
typedef std::map<std::string, Commands> CustomCommands; typedef std::map<std::string, Commands> BuildRules;
bool Matches(const char* name); bool Matches(const char* name);
void SetGroupRegex(const char* regex) void SetGroupRegex(const char* regex)
{ m_GroupRegex.compile(regex); } { m_GroupRegex.compile(regex); }
void AddSource(const char* name) void AddSource(const char* name);
{ m_Sources.push_back(name); }
void AddCustomCommand(const cmCustomCommand &cmd); void AddCustomCommand(const cmCustomCommand &cmd);
const char* GetName() const const char* GetName() const
{ return m_Name.c_str(); } { return m_Name.c_str(); }
const std::vector<std::string>& GetSources() const const BuildRules& GetBuildRules() const
{ return m_Sources; } { return m_BuildRules; }
const CustomCommands& GetCustomCommands() const
{ return m_CustomCommands; }
private: private:
/** /**
@ -104,14 +101,11 @@ private:
cmRegularExpression m_GroupRegex; 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<std::string> m_Sources; BuildRules m_BuildRules;
/**
* The custom commands in this group and their corresponding sources.
*/
CustomCommands m_CustomCommands;
}; };
#endif #endif