cmCustomCommand.cxx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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()
  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. Backtrace(r.Backtrace),
  29. Comment(r.Comment),
  30. WorkingDirectory(r.WorkingDirectory),
  31. HaveComment(r.HaveComment),
  32. EscapeAllowMakeVars(r.EscapeAllowMakeVars),
  33. EscapeOldStyle(r.EscapeOldStyle),
  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. Backtrace(),
  71. Comment(comment?comment:""),
  72. WorkingDirectory(workingDirectory?workingDirectory:""),
  73. HaveComment(comment?true:false),
  74. EscapeAllowMakeVars(false),
  75. EscapeOldStyle(true)
  76. {
  77. if(mf)
  78. {
  79. this->Backtrace = mf->GetBacktrace();
  80. }
  81. }
  82. //----------------------------------------------------------------------------
  83. cmCustomCommand::~cmCustomCommand()
  84. {
  85. }
  86. //----------------------------------------------------------------------------
  87. const std::vector<std::string>& cmCustomCommand::GetOutputs() const
  88. {
  89. return this->Outputs;
  90. }
  91. //----------------------------------------------------------------------------
  92. const std::vector<std::string>& cmCustomCommand::GetByproducts() const
  93. {
  94. return this->Byproducts;
  95. }
  96. //----------------------------------------------------------------------------
  97. const std::vector<std::string>& cmCustomCommand::GetDepends() const
  98. {
  99. return this->Depends;
  100. }
  101. //----------------------------------------------------------------------------
  102. const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
  103. {
  104. return this->CommandLines;
  105. }
  106. //----------------------------------------------------------------------------
  107. const char* cmCustomCommand::GetComment() const
  108. {
  109. const char* no_comment = 0;
  110. return this->HaveComment? this->Comment.c_str() : no_comment;
  111. }
  112. //----------------------------------------------------------------------------
  113. void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
  114. {
  115. this->CommandLines.insert(this->CommandLines.end(),
  116. commandLines.begin(), commandLines.end());
  117. }
  118. //----------------------------------------------------------------------------
  119. void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
  120. {
  121. this->Depends.insert(this->Depends.end(), depends.begin(), depends.end());
  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. }