cmCustomCommand.cxx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. Byproducts(r.Byproducts),
  26. Depends(r.Depends),
  27. CommandLines(r.CommandLines),
  28. HaveComment(r.HaveComment),
  29. Comment(r.Comment),
  30. WorkingDirectory(r.WorkingDirectory),
  31. EscapeAllowMakeVars(r.EscapeAllowMakeVars),
  32. EscapeOldStyle(r.EscapeOldStyle),
  33. Backtrace(r.Backtrace),
  34. UsesTerminal(r.UsesTerminal)
  35. {
  36. }
  37. //----------------------------------------------------------------------------
  38. cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r)
  39. {
  40. if(this == &r)
  41. {
  42. return *this;
  43. }
  44. this->Outputs = r.Outputs;
  45. this->Byproducts= r.Byproducts;
  46. this->Depends = r.Depends;
  47. this->CommandLines = r.CommandLines;
  48. this->HaveComment = r.HaveComment;
  49. this->Comment = r.Comment;
  50. this->WorkingDirectory = r.WorkingDirectory;
  51. this->EscapeAllowMakeVars = r.EscapeAllowMakeVars;
  52. this->EscapeOldStyle = r.EscapeOldStyle;
  53. this->ImplicitDepends = r.ImplicitDepends;
  54. this->Backtrace = r.Backtrace;
  55. this->UsesTerminal = r.UsesTerminal;
  56. return *this;
  57. }
  58. //----------------------------------------------------------------------------
  59. cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
  60. const std::vector<std::string>& outputs,
  61. const std::vector<std::string>& byproducts,
  62. const std::vector<std::string>& depends,
  63. const cmCustomCommandLines& commandLines,
  64. const char* comment,
  65. const char* workingDirectory):
  66. Outputs(outputs),
  67. Byproducts(byproducts),
  68. Depends(depends),
  69. CommandLines(commandLines),
  70. HaveComment(comment?true:false),
  71. Comment(comment?comment:""),
  72. WorkingDirectory(workingDirectory?workingDirectory:""),
  73. EscapeAllowMakeVars(false),
  74. EscapeOldStyle(true),
  75. Backtrace(NULL)
  76. {
  77. this->EscapeOldStyle = true;
  78. this->EscapeAllowMakeVars = false;
  79. if(mf)
  80. {
  81. this->Backtrace = mf->GetBacktrace();
  82. }
  83. }
  84. //----------------------------------------------------------------------------
  85. cmCustomCommand::~cmCustomCommand()
  86. {
  87. }
  88. //----------------------------------------------------------------------------
  89. const std::vector<std::string>& cmCustomCommand::GetOutputs() const
  90. {
  91. return this->Outputs;
  92. }
  93. //----------------------------------------------------------------------------
  94. const std::vector<std::string>& cmCustomCommand::GetByproducts() const
  95. {
  96. return this->Byproducts;
  97. }
  98. //----------------------------------------------------------------------------
  99. const std::vector<std::string>& cmCustomCommand::GetDepends() const
  100. {
  101. return this->Depends;
  102. }
  103. //----------------------------------------------------------------------------
  104. const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
  105. {
  106. return this->CommandLines;
  107. }
  108. //----------------------------------------------------------------------------
  109. const char* cmCustomCommand::GetComment() const
  110. {
  111. const char* no_comment = 0;
  112. return this->HaveComment? this->Comment.c_str() : no_comment;
  113. }
  114. //----------------------------------------------------------------------------
  115. void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
  116. {
  117. this->CommandLines.insert(this->CommandLines.end(),
  118. commandLines.begin(), commandLines.end());
  119. }
  120. //----------------------------------------------------------------------------
  121. void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
  122. {
  123. this->Depends.insert(this->Depends.end(), depends.begin(), depends.end());
  124. }
  125. //----------------------------------------------------------------------------
  126. bool cmCustomCommand::GetEscapeOldStyle() const
  127. {
  128. return this->EscapeOldStyle;
  129. }
  130. //----------------------------------------------------------------------------
  131. void cmCustomCommand::SetEscapeOldStyle(bool b)
  132. {
  133. this->EscapeOldStyle = b;
  134. }
  135. //----------------------------------------------------------------------------
  136. bool cmCustomCommand::GetEscapeAllowMakeVars() const
  137. {
  138. return this->EscapeAllowMakeVars;
  139. }
  140. //----------------------------------------------------------------------------
  141. void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
  142. {
  143. this->EscapeAllowMakeVars = b;
  144. }
  145. //----------------------------------------------------------------------------
  146. cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
  147. {
  148. return this->Backtrace;
  149. }
  150. //----------------------------------------------------------------------------
  151. cmCustomCommand::ImplicitDependsList const&
  152. cmCustomCommand::GetImplicitDepends() const
  153. {
  154. return this->ImplicitDepends;
  155. }
  156. //----------------------------------------------------------------------------
  157. void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
  158. {
  159. this->ImplicitDepends = l;
  160. }
  161. //----------------------------------------------------------------------------
  162. void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
  163. {
  164. this->ImplicitDepends.insert(this->ImplicitDepends.end(),
  165. l.begin(), l.end());
  166. }
  167. //----------------------------------------------------------------------------
  168. bool cmCustomCommand::GetUsesTerminal() const
  169. {
  170. return this->UsesTerminal;
  171. }
  172. //----------------------------------------------------------------------------
  173. void cmCustomCommand::SetUsesTerminal(bool b)
  174. {
  175. this->UsesTerminal = b;
  176. }