better custom rules

This commit is contained in:
Ken Martin 2001-05-04 09:39:05 -04:00
parent faaadc4a08
commit 4d9b2f59cc
5 changed files with 76 additions and 48 deletions

View File

@ -271,28 +271,32 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
// Loop through every custom command generating code from the
// current source.
// build up the depends and outputs and commands
cmSourceGroup::CommandFiles totalCommand;
std::string totalCommandStr;
for(cmSourceGroup::Commands::const_iterator c = commands.begin();
c != commands.end(); ++c)
{
std::string command = c->first;
const cmSourceGroup::CommandFiles& commandFiles = c->second;
this->WriteCustomRule(fout, source.c_str(), command.c_str(), commandFiles.m_Depends,
commandFiles.m_Outputs);
// Create a dummy file with the name of the source if it does
// not exist
if(commandFiles.m_Outputs.size() == 0)
{
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
dummyFile += "/";
dummyFile += source;
if(!cmSystemTools::FileExists(dummyFile.c_str()))
{
std::ofstream fout(dummyFile.c_str());
fout << "Dummy file created by cmake as unused source for utility command.\n";
}
}
totalCommandStr += "\n\t";
totalCommandStr += c->first;
totalCommand.Merge(c->second);
}
// Create a dummy file with the name of the source if it does
// not exist
if(totalCommand.m_Outputs.empty())
{
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
dummyFile += "/";
dummyFile += source;
if(!cmSystemTools::FileExists(dummyFile.c_str()))
{
std::ofstream fout(dummyFile.c_str());
fout << "Dummy file created by cmake as unused source for utility command.\n";
}
}
this->WriteCustomRule(fout, source.c_str(), totalCommandStr.c_str(),
totalCommand.m_Depends,
totalCommand.m_Outputs);
fout << "# End Source File\n";
}
@ -341,7 +345,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
if(outputs.size() == 0)
{
fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"";
fout << "\n " << command << "\n\n";
fout << command << "\n\n";
}
// Write a rule for every output generated by this command.
@ -356,7 +360,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
{
fout << " \"" << d->c_str() << "\"";
}
fout << "\n " << command << "\n\n";
fout << command << "\n\n";
}
fout << "# End Custom Build\n\n";

View File

@ -271,28 +271,32 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
// Loop through every custom command generating code from the
// current source.
// build up the depends and outputs and commands
cmSourceGroup::CommandFiles totalCommand;
std::string totalCommandStr;
for(cmSourceGroup::Commands::const_iterator c = commands.begin();
c != commands.end(); ++c)
{
std::string command = c->first;
const cmSourceGroup::CommandFiles& commandFiles = c->second;
this->WriteCustomRule(fout, source.c_str(), command.c_str(), commandFiles.m_Depends,
commandFiles.m_Outputs);
// Create a dummy file with the name of the source if it does
// not exist
if(commandFiles.m_Outputs.size() == 0)
{
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
dummyFile += "/";
dummyFile += source;
if(!cmSystemTools::FileExists(dummyFile.c_str()))
{
std::ofstream fout(dummyFile.c_str());
fout << "Dummy file created by cmake as unused source for utility command.\n";
}
}
totalCommandStr += "\n\t";
totalCommandStr += c->first;
totalCommand.Merge(c->second);
}
// Create a dummy file with the name of the source if it does
// not exist
if(totalCommand.m_Outputs.empty())
{
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
dummyFile += "/";
dummyFile += source;
if(!cmSystemTools::FileExists(dummyFile.c_str()))
{
std::ofstream fout(dummyFile.c_str());
fout << "Dummy file created by cmake as unused source for utility command.\n";
}
}
this->WriteCustomRule(fout, source.c_str(), totalCommandStr.c_str(),
totalCommand.m_Depends,
totalCommand.m_Outputs);
fout << "# End Source File\n";
}
@ -341,7 +345,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
if(outputs.size() == 0)
{
fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"";
fout << "\n " << command << "\n\n";
fout << command << "\n\n";
}
// Write a rule for every output generated by this command.
@ -356,7 +360,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
{
fout << " \"" << d->c_str() << "\"";
}
fout << "\n " << command << "\n\n";
fout << command << "\n\n";
}
fout << "# End Custom Build\n\n";

View File

@ -121,3 +121,19 @@ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
commandFiles.m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end());
commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end());
}
void cmSourceGroup::CommandFiles::Merge(const CommandFiles &r)
{
std::set<std::string>::const_iterator dep = r.m_Depends.begin();
std::set<std::string>::const_iterator out = r.m_Outputs.begin();
for (;dep != r.m_Depends.end(); ++dep)
{
this->m_Depends.insert(*dep);
}
for (;out != r.m_Outputs.end(); ++out)
{
this->m_Outputs.insert(*out);
}
}

View File

@ -65,6 +65,8 @@ public:
CommandFiles(const CommandFiles& r):
m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {}
void Merge(const CommandFiles &r);
std::set<std::string> m_Outputs;
std::set<std::string> m_Depends;
};

View File

@ -103,13 +103,14 @@ void cmVTKWrapJavaCommand::FinalPass()
// first we add the rules for all the .h to Java.cxx files
int lastClass = m_WrapClasses.size();
std::vector<std::string> depends;
std::vector<std::string> depends2;
std::string wjava = "${VTK_WRAP_JAVA_EXE}";
std::string pjava = "${VTK_PARSE_JAVA_EXE}";
std::string hints = "${VTK_WRAP_HINTS}";
// wrap all the .h files
depends.push_back(wjava);
depends.push_back(pjava);
depends2.push_back(pjava);
for(int classNum = 0; classNum < lastClass; classNum++)
{
m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str());
@ -117,17 +118,18 @@ void cmVTKWrapJavaCommand::FinalPass()
// wrap java
std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx";
std::string res2 = m_OriginalNames[classNum] + ".java";
std::vector<std::string> resvec;
resvec.push_back(res);
resvec.push_back(res2);
std::string cmd = wjava + " " + m_WrapHeaders[classNum] + " "
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx\\\n\t" +
pjava + " " + m_WrapHeaders[classNum] + " "
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_OriginalNames[classNum] + ".java";
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx";
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
cmd.c_str(), depends,
resvec, m_LibraryName.c_str());
res.c_str(), m_LibraryName.c_str());
cmd = pjava + " " + m_WrapHeaders[classNum] + " "
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_OriginalNames[classNum] + ".java";
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
cmd.c_str(), depends2,
res2.c_str(), m_LibraryName.c_str());
}
}