cmCustomCommand.cxx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCustomCommand.h"
  11. #include "cmMakefile.h"
  12. #include <cmsys/auto_ptr.hxx>
  13. //----------------------------------------------------------------------------
  14. cmCustomCommand::cmCustomCommand()
  15. : Backtrace(NULL)
  16. {
  17. this->HaveComment = false;
  18. this->EscapeOldStyle = true;
  19. this->EscapeAllowMakeVars = false;
  20. this->UsesTerminal = false;
  21. }
  22. //----------------------------------------------------------------------------
  23. cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
  24. Outputs(r.Outputs),
  25. Depends(r.Depends),
  26. CommandLines(r.CommandLines),
  27. HaveComment(r.HaveComment),
  28. Comment(r.Comment),
  29. WorkingDirectory(r.WorkingDirectory),
  30. EscapeAllowMakeVars(r.EscapeAllowMakeVars),
  31. EscapeOldStyle(r.EscapeOldStyle),
  32. Backtrace(r.Backtrace),
  33. UsesTerminal(r.UsesTerminal)
  34. {
  35. }
  36. //----------------------------------------------------------------------------
  37. cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r)
  38. {
  39. if(this == &r)
  40. {
  41. return *this;
  42. }
  43. this->Outputs = r.Outputs;
  44. this->Depends = r.Depends;
  45. this->CommandLines = r.CommandLines;
  46. this->HaveComment = r.HaveComment;
  47. this->Comment = r.Comment;
  48. this->WorkingDirectory = r.WorkingDirectory;
  49. this->EscapeAllowMakeVars = r.EscapeAllowMakeVars;
  50. this->EscapeOldStyle = r.EscapeOldStyle;
  51. this->ImplicitDepends = r.ImplicitDepends;
  52. this->Backtrace = r.Backtrace;
  53. this->UsesTerminal = r.UsesTerminal;
  54. return *this;
  55. }
  56. //----------------------------------------------------------------------------
  57. cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
  58. const std::vector<std::string>& outputs,
  59. const std::vector<std::string>& depends,
  60. const cmCustomCommandLines& commandLines,
  61. const char* comment,
  62. const char* workingDirectory):
  63. Outputs(outputs),
  64. Depends(depends),
  65. CommandLines(commandLines),
  66. HaveComment(comment?true:false),
  67. Comment(comment?comment:""),
  68. WorkingDirectory(workingDirectory?workingDirectory:""),
  69. EscapeAllowMakeVars(false),
  70. EscapeOldStyle(true),
  71. Backtrace(NULL)
  72. {
  73. this->EscapeOldStyle = true;
  74. this->EscapeAllowMakeVars = false;
  75. if(mf)
  76. {
  77. this->Backtrace = mf->GetBacktrace();
  78. }
  79. }
  80. //----------------------------------------------------------------------------
  81. cmCustomCommand::~cmCustomCommand()
  82. {
  83. }
  84. //----------------------------------------------------------------------------
  85. const std::vector<std::string>& cmCustomCommand::GetOutputs() const
  86. {
  87. return this->Outputs;
  88. }
  89. //----------------------------------------------------------------------------
  90. const std::vector<std::string>& cmCustomCommand::GetDepends() const
  91. {
  92. return this->Depends;
  93. }
  94. //----------------------------------------------------------------------------
  95. const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
  96. {
  97. return this->CommandLines;
  98. }
  99. //----------------------------------------------------------------------------
  100. const char* cmCustomCommand::GetComment() const
  101. {
  102. const char* no_comment = 0;
  103. return this->HaveComment? this->Comment.c_str() : no_comment;
  104. }
  105. //----------------------------------------------------------------------------
  106. void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
  107. {
  108. for(cmCustomCommandLines::const_iterator i=commandLines.begin();
  109. i != commandLines.end(); ++i)
  110. {
  111. this->CommandLines.push_back(*i);
  112. }
  113. }
  114. //----------------------------------------------------------------------------
  115. void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
  116. {
  117. for(std::vector<std::string>::const_iterator i=depends.begin();
  118. i != depends.end(); ++i)
  119. {
  120. this->Depends.push_back(*i);
  121. }
  122. }
  123. //----------------------------------------------------------------------------
  124. bool cmCustomCommand::GetEscapeOldStyle() const
  125. {
  126. return this->EscapeOldStyle;
  127. }
  128. //----------------------------------------------------------------------------
  129. void cmCustomCommand::SetEscapeOldStyle(bool b)
  130. {
  131. this->EscapeOldStyle = b;
  132. }
  133. //----------------------------------------------------------------------------
  134. bool cmCustomCommand::GetEscapeAllowMakeVars() const
  135. {
  136. return this->EscapeAllowMakeVars;
  137. }
  138. //----------------------------------------------------------------------------
  139. void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
  140. {
  141. this->EscapeAllowMakeVars = b;
  142. }
  143. //----------------------------------------------------------------------------
  144. cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
  145. {
  146. return this->Backtrace;
  147. }
  148. //----------------------------------------------------------------------------
  149. cmCustomCommand::ImplicitDependsList const&
  150. cmCustomCommand::GetImplicitDepends() const
  151. {
  152. return this->ImplicitDepends;
  153. }
  154. //----------------------------------------------------------------------------
  155. void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
  156. {
  157. this->ImplicitDepends = l;
  158. }
  159. //----------------------------------------------------------------------------
  160. void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
  161. {
  162. this->ImplicitDepends.insert(this->ImplicitDepends.end(),
  163. l.begin(), l.end());
  164. }
  165. //----------------------------------------------------------------------------
  166. bool cmCustomCommand::GetUsesTerminal() const
  167. {
  168. return this->UsesTerminal;
  169. }
  170. //----------------------------------------------------------------------------
  171. void cmCustomCommand::SetUsesTerminal(bool b)
  172. {
  173. this->UsesTerminal = b;
  174. }