[cmake-commits] king committed cmAddCustomCommandCommand.cxx 1.33
1.34 cmAddCustomCommandCommand.h 1.25 1.26 cmCustomCommand.cxx
1.21 1.22 cmCustomCommand.h 1.19 1.20
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Oct 4 15:24:29 EDT 2006
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv13968/Source
Modified Files:
cmAddCustomCommandCommand.cxx cmAddCustomCommandCommand.h
cmCustomCommand.cxx cmCustomCommand.h
Log Message:
ENH: Added APPEND option to ADD_CUSTOM_COMMAND to allow extra dependencies to be connected later. This is useful to create one rule and then have a macro add things to it later. This addresses bug#2151.
Index: cmAddCustomCommandCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.cxx,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- cmAddCustomCommandCommand.cxx 28 Sep 2006 20:40:34 -0000 1.33
+++ cmAddCustomCommandCommand.cxx 4 Oct 2006 19:24:24 -0000 1.34
@@ -18,6 +18,8 @@
#include "cmTarget.h"
+#include "cmSourceFile.h"
+
// cmAddCustomCommandCommand
bool cmAddCustomCommandCommand::InitialPass(
std::vector<std::string> const& args)
@@ -37,6 +39,7 @@
const char* comment = 0;
std::vector<std::string> depends, outputs, output;
bool verbatim = false;
+ bool append = false;
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
@@ -96,6 +99,10 @@
{
verbatim = true;
}
+ else if(copy == "APPEND")
+ {
+ append = true;
+ }
else if(copy == "TARGET")
{
doing = doing_target;
@@ -210,6 +217,11 @@
"Wrong syntax. A TARGET and OUTPUT can not both be specified.");
return false;
}
+ if(append && output.empty())
+ {
+ this->SetError("given APPEND option with no OUTPUT.");
+ return false;
+ }
// Make sure the output names and locations are safe.
if(!this->CheckOutputs(output) || !this->CheckOutputs(outputs))
@@ -217,6 +229,29 @@
return false;
}
+ // Check for an append request.
+ if(append)
+ {
+ // Lookup an existing command.
+ if(cmSourceFile* sf =
+ this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+ {
+ if(cmCustomCommand* cc = sf->GetCustomCommand())
+ {
+ cc->AppendCommands(commandLines);
+ cc->AppendDepends(depends);
+ return true;
+ }
+ }
+
+ // No command for this output exists.
+ cmOStringStream e;
+ e << "given APPEND option with output \"" << output[0].c_str()
+ << "\" which is not already a custom command output.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
// Choose which mode of the command to use.
bool escapeOldStyle = !verbatim;
if(source.empty() && output.empty())
Index: cmAddCustomCommandCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- cmAddCustomCommandCommand.h 2 Oct 2006 14:20:52 -0000 1.25
+++ cmAddCustomCommandCommand.h 4 Oct 2006 19:24:24 -0000 1.26
@@ -72,7 +72,7 @@
" [MAIN_DEPENDENCY depend]\n"
" [DEPENDS [depends...]]\n"
" [WORKING_DIRECTORY dir]\n"
- " [COMMENT comment] [VERBATIM])\n"
+ " [COMMENT comment] [VERBATIM] [APPEND])\n"
"This defines a new command that can be executed during the build "
"process. The outputs named should be listed as source files in the "
"target for which they are to be generated. "
@@ -104,7 +104,15 @@
"Studio 7 or later. For all other generators PRE_BUILD "
"will be treated as PRE_LINK. "
"If WORKING_DIRECTORY is specified the command will be executed "
- "in the directory given.\n"
+ "in the directory given."
+ "\n"
+ "If APPEND is specified the COMMAND and DEPENDS option values "
+ "are appended to the custom command for the first output specified. "
+ "There must have already been a previous call to this command with "
+ "the same output. The COMMENT, WORKING_DIRECTORY, and MAIN_DEPENDENCY "
+ "options are currently ignored when APPEND is given, "
+ "but may be used in the future."
+ "\n"
"If VERBATIM is given then all the arguments to the commands will be "
"passed exactly as specified no matter the build tool used. "
"Note that one level of escapes is still used by the CMake language "
Index: cmCustomCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCustomCommand.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- cmCustomCommand.cxx 28 Sep 2006 20:40:35 -0000 1.21
+++ cmCustomCommand.cxx 4 Oct 2006 19:24:24 -0000 1.22
@@ -95,6 +95,26 @@
}
//----------------------------------------------------------------------------
+void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
+{
+ for(cmCustomCommandLines::const_iterator i=commandLines.begin();
+ i != commandLines.end(); ++i)
+ {
+ this->CommandLines.push_back(*i);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
+{
+ for(std::vector<std::string>::const_iterator i=depends.begin();
+ i != depends.end(); ++i)
+ {
+ this->Depends.push_back(*i);
+ }
+}
+
+//----------------------------------------------------------------------------
bool cmCustomCommand::GetEscapeOldStyle() const
{
return this->EscapeOldStyle;
Index: cmCustomCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCustomCommand.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cmCustomCommand.h 28 Sep 2006 20:40:35 -0000 1.19
+++ cmCustomCommand.h 4 Oct 2006 19:24:24 -0000 1.20
@@ -53,6 +53,12 @@
/** Get the comment string for the command. */
const char* GetComment() const;
+ /** Append to the list of command lines. */
+ void AppendCommands(const cmCustomCommandLines& commandLines);
+
+ /** Append to the list of dependencies. */
+ void AppendDepends(const std::vector<std::string>& depends);
+
/** Set/Get whether old-style escaping should be used. */
bool GetEscapeOldStyle() const;
void SetEscapeOldStyle(bool b);
More information about the Cmake-commits
mailing list