summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2001-05-04 13:39:05 (GMT)
committerKen Martin <ken.martin@kitware.com>2001-05-04 13:39:05 (GMT)
commit4d9b2f59cc4da52e93b6a5d647dba06828d258f3 (patch)
tree7552b7efe08da399577a5fc3846ac13635bd81b2 /Source
parentfaaadc4a08e8103e25346a437fc203e05b43566c (diff)
downloadCMake-4d9b2f59cc4da52e93b6a5d647dba06828d258f3.zip
CMake-4d9b2f59cc4da52e93b6a5d647dba06828d258f3.tar.gz
CMake-4d9b2f59cc4da52e93b6a5d647dba06828d258f3.tar.bz2
better custom rules
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDSPMakefile.cxx44
-rw-r--r--Source/cmDSPWriter.cxx44
-rw-r--r--Source/cmSourceGroup.cxx16
-rw-r--r--Source/cmSourceGroup.h2
-rw-r--r--Source/cmVTKWrapJavaCommand.cxx18
5 files changed, 76 insertions, 48 deletions
diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx
index 78bcb9e..56fb420 100644
--- a/Source/cmDSPMakefile.cxx
+++ b/Source/cmDSPMakefile.cxx
@@ -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";
diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx
index 78bcb9e..56fb420 100644
--- a/Source/cmDSPWriter.cxx
+++ b/Source/cmDSPWriter.cxx
@@ -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";
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index 49b2bd7..8935a07 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -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);
+ }
+}
+
+
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index 9162f2b..479abd6 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -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;
};
diff --git a/Source/cmVTKWrapJavaCommand.cxx b/Source/cmVTKWrapJavaCommand.cxx
index ec9fff1..d828e00 100644
--- a/Source/cmVTKWrapJavaCommand.cxx
+++ b/Source/cmVTKWrapJavaCommand.cxx
@@ -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());
}
}