better custom rules
This commit is contained in:
parent
faaadc4a08
commit
4d9b2f59cc
@ -271,28 +271,32 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
|
|||||||
|
|
||||||
// Loop through every custom command generating code from the
|
// Loop through every custom command generating code from the
|
||||||
// current source.
|
// current source.
|
||||||
|
// build up the depends and outputs and commands
|
||||||
|
cmSourceGroup::CommandFiles totalCommand;
|
||||||
|
std::string totalCommandStr;
|
||||||
for(cmSourceGroup::Commands::const_iterator c = commands.begin();
|
for(cmSourceGroup::Commands::const_iterator c = commands.begin();
|
||||||
c != commands.end(); ++c)
|
c != commands.end(); ++c)
|
||||||
{
|
{
|
||||||
std::string command = c->first;
|
totalCommandStr += "\n\t";
|
||||||
const cmSourceGroup::CommandFiles& commandFiles = c->second;
|
totalCommandStr += c->first;
|
||||||
this->WriteCustomRule(fout, source.c_str(), command.c_str(), commandFiles.m_Depends,
|
totalCommand.Merge(c->second);
|
||||||
commandFiles.m_Outputs);
|
}
|
||||||
// Create a dummy file with the name of the source if it does
|
// Create a dummy file with the name of the source if it does
|
||||||
// not exist
|
// not exist
|
||||||
if(commandFiles.m_Outputs.size() == 0)
|
if(totalCommand.m_Outputs.empty())
|
||||||
|
{
|
||||||
|
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
|
||||||
|
dummyFile += "/";
|
||||||
|
dummyFile += source;
|
||||||
|
if(!cmSystemTools::FileExists(dummyFile.c_str()))
|
||||||
{
|
{
|
||||||
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
|
std::ofstream fout(dummyFile.c_str());
|
||||||
dummyFile += "/";
|
fout << "Dummy file created by cmake as unused source for utility command.\n";
|
||||||
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";
|
fout << "# End Source File\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +345,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
|
|||||||
if(outputs.size() == 0)
|
if(outputs.size() == 0)
|
||||||
{
|
{
|
||||||
fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"";
|
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.
|
// 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 << " \"" << d->c_str() << "\"";
|
||||||
}
|
}
|
||||||
fout << "\n " << command << "\n\n";
|
fout << command << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
fout << "# End Custom Build\n\n";
|
fout << "# End Custom Build\n\n";
|
||||||
|
@ -271,28 +271,32 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
|
|||||||
|
|
||||||
// Loop through every custom command generating code from the
|
// Loop through every custom command generating code from the
|
||||||
// current source.
|
// current source.
|
||||||
|
// build up the depends and outputs and commands
|
||||||
|
cmSourceGroup::CommandFiles totalCommand;
|
||||||
|
std::string totalCommandStr;
|
||||||
for(cmSourceGroup::Commands::const_iterator c = commands.begin();
|
for(cmSourceGroup::Commands::const_iterator c = commands.begin();
|
||||||
c != commands.end(); ++c)
|
c != commands.end(); ++c)
|
||||||
{
|
{
|
||||||
std::string command = c->first;
|
totalCommandStr += "\n\t";
|
||||||
const cmSourceGroup::CommandFiles& commandFiles = c->second;
|
totalCommandStr += c->first;
|
||||||
this->WriteCustomRule(fout, source.c_str(), command.c_str(), commandFiles.m_Depends,
|
totalCommand.Merge(c->second);
|
||||||
commandFiles.m_Outputs);
|
}
|
||||||
// Create a dummy file with the name of the source if it does
|
// Create a dummy file with the name of the source if it does
|
||||||
// not exist
|
// not exist
|
||||||
if(commandFiles.m_Outputs.size() == 0)
|
if(totalCommand.m_Outputs.empty())
|
||||||
|
{
|
||||||
|
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
|
||||||
|
dummyFile += "/";
|
||||||
|
dummyFile += source;
|
||||||
|
if(!cmSystemTools::FileExists(dummyFile.c_str()))
|
||||||
{
|
{
|
||||||
std::string dummyFile = m_Makefile->GetStartOutputDirectory();
|
std::ofstream fout(dummyFile.c_str());
|
||||||
dummyFile += "/";
|
fout << "Dummy file created by cmake as unused source for utility command.\n";
|
||||||
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";
|
fout << "# End Source File\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +345,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
|
|||||||
if(outputs.size() == 0)
|
if(outputs.size() == 0)
|
||||||
{
|
{
|
||||||
fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"";
|
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.
|
// 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 << " \"" << d->c_str() << "\"";
|
||||||
}
|
}
|
||||||
fout << "\n " << command << "\n\n";
|
fout << command << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
fout << "# End Custom Build\n\n";
|
fout << "# End Custom Build\n\n";
|
||||||
|
@ -121,3 +121,19 @@ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
|
|||||||
commandFiles.m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end());
|
commandFiles.m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end());
|
||||||
commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ public:
|
|||||||
CommandFiles(const CommandFiles& r):
|
CommandFiles(const CommandFiles& r):
|
||||||
m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {}
|
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_Outputs;
|
||||||
std::set<std::string> m_Depends;
|
std::set<std::string> m_Depends;
|
||||||
};
|
};
|
||||||
|
@ -103,13 +103,14 @@ void cmVTKWrapJavaCommand::FinalPass()
|
|||||||
// first we add the rules for all the .h to Java.cxx files
|
// first we add the rules for all the .h to Java.cxx files
|
||||||
int lastClass = m_WrapClasses.size();
|
int lastClass = m_WrapClasses.size();
|
||||||
std::vector<std::string> depends;
|
std::vector<std::string> depends;
|
||||||
|
std::vector<std::string> depends2;
|
||||||
std::string wjava = "${VTK_WRAP_JAVA_EXE}";
|
std::string wjava = "${VTK_WRAP_JAVA_EXE}";
|
||||||
std::string pjava = "${VTK_PARSE_JAVA_EXE}";
|
std::string pjava = "${VTK_PARSE_JAVA_EXE}";
|
||||||
std::string hints = "${VTK_WRAP_HINTS}";
|
std::string hints = "${VTK_WRAP_HINTS}";
|
||||||
|
|
||||||
// wrap all the .h files
|
// wrap all the .h files
|
||||||
depends.push_back(wjava);
|
depends.push_back(wjava);
|
||||||
depends.push_back(pjava);
|
depends2.push_back(pjava);
|
||||||
for(int classNum = 0; classNum < lastClass; classNum++)
|
for(int classNum = 0; classNum < lastClass; classNum++)
|
||||||
{
|
{
|
||||||
m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str());
|
m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str());
|
||||||
@ -117,17 +118,18 @@ void cmVTKWrapJavaCommand::FinalPass()
|
|||||||
// wrap java
|
// wrap java
|
||||||
std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx";
|
std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx";
|
||||||
std::string res2 = m_OriginalNames[classNum] + ".java";
|
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] + " "
|
std::string cmd = wjava + " " + m_WrapHeaders[classNum] + " "
|
||||||
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx\\\n\t" +
|
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx";
|
||||||
pjava + " " + m_WrapHeaders[classNum] + " "
|
|
||||||
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_OriginalNames[classNum] + ".java";
|
|
||||||
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
|
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
|
||||||
cmd.c_str(), depends,
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user