cmCustomCommand.cxx 5.7 KB

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