cmCustomCommand.cxx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCustomCommand.h"
  4. #include <cassert>
  5. #include <utility>
  6. #include <cmext/algorithm>
  7. #include "cmStateSnapshot.h"
  8. const std::vector<std::string>& cmCustomCommand::GetOutputs() const
  9. {
  10. return this->Outputs;
  11. }
  12. void cmCustomCommand::SetOutputs(std::vector<std::string> outputs)
  13. {
  14. this->Outputs = std::move(outputs);
  15. }
  16. void cmCustomCommand::SetOutputs(std::string output)
  17. {
  18. this->Outputs = { std::move(output) };
  19. }
  20. const std::vector<std::string>& cmCustomCommand::GetByproducts() const
  21. {
  22. return this->Byproducts;
  23. }
  24. void cmCustomCommand::SetByproducts(std::vector<std::string> byproducts)
  25. {
  26. this->Byproducts = std::move(byproducts);
  27. }
  28. const std::vector<std::string>& cmCustomCommand::GetDepends() const
  29. {
  30. return this->Depends;
  31. }
  32. void cmCustomCommand::SetDepends(std::vector<std::string> depends)
  33. {
  34. if (this->HasMainDependency_) {
  35. depends.insert(depends.begin(), std::move(this->Depends[0]));
  36. }
  37. Depends = std::move(depends);
  38. }
  39. const std::string& cmCustomCommand::GetMainDependency() const
  40. {
  41. assert(this->HasMainDependency_);
  42. return this->Depends[0];
  43. }
  44. void cmCustomCommand::SetMainDependency(std::string main_dependency)
  45. {
  46. if (this->HasMainDependency_) {
  47. assert(!main_dependency.empty());
  48. this->Depends[0] = std::move(main_dependency);
  49. } else if (main_dependency.empty()) {
  50. // Do nothing.
  51. } else {
  52. this->Depends.insert(this->Depends.begin(), std::move(main_dependency));
  53. this->HasMainDependency_ = true;
  54. }
  55. }
  56. const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
  57. {
  58. return this->CommandLines;
  59. }
  60. void cmCustomCommand::SetCommandLines(cmCustomCommandLines commandLines)
  61. {
  62. this->CommandLines = std::move(commandLines);
  63. }
  64. const char* cmCustomCommand::GetComment() const
  65. {
  66. const char* no_comment = nullptr;
  67. return this->HaveComment ? this->Comment.c_str() : no_comment;
  68. }
  69. void cmCustomCommand::SetComment(const char* comment)
  70. {
  71. this->Comment = comment ? comment : "";
  72. this->HaveComment = (comment != nullptr);
  73. }
  74. void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
  75. {
  76. cm::append(this->CommandLines, commandLines);
  77. }
  78. void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
  79. {
  80. cm::append(this->Depends, depends);
  81. }
  82. bool cmCustomCommand::GetEscapeOldStyle() const
  83. {
  84. return this->EscapeOldStyle;
  85. }
  86. void cmCustomCommand::SetEscapeOldStyle(bool b)
  87. {
  88. this->EscapeOldStyle = b;
  89. }
  90. bool cmCustomCommand::GetEscapeAllowMakeVars() const
  91. {
  92. return this->EscapeAllowMakeVars;
  93. }
  94. void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
  95. {
  96. this->EscapeAllowMakeVars = b;
  97. }
  98. cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
  99. {
  100. return this->Backtrace;
  101. }
  102. void cmCustomCommand::SetBacktrace(cmListFileBacktrace lfbt)
  103. {
  104. this->Backtrace = std::move(lfbt);
  105. }
  106. cmImplicitDependsList const& cmCustomCommand::GetImplicitDepends() const
  107. {
  108. return this->ImplicitDepends;
  109. }
  110. void cmCustomCommand::SetImplicitDepends(cmImplicitDependsList const& l)
  111. {
  112. this->ImplicitDepends = l;
  113. }
  114. void cmCustomCommand::AppendImplicitDepends(cmImplicitDependsList const& l)
  115. {
  116. cm::append(this->ImplicitDepends, l);
  117. }
  118. bool cmCustomCommand::GetUsesTerminal() const
  119. {
  120. return this->UsesTerminal;
  121. }
  122. void cmCustomCommand::SetUsesTerminal(bool b)
  123. {
  124. this->UsesTerminal = b;
  125. }
  126. bool cmCustomCommand::GetCommandExpandLists() const
  127. {
  128. return this->CommandExpandLists;
  129. }
  130. void cmCustomCommand::SetCommandExpandLists(bool b)
  131. {
  132. this->CommandExpandLists = b;
  133. }
  134. bool cmCustomCommand::GetDependsExplicitOnly() const
  135. {
  136. return this->DependsExplicitOnly;
  137. }
  138. void cmCustomCommand::SetDependsExplicitOnly(bool b)
  139. {
  140. this->DependsExplicitOnly = b;
  141. }
  142. const std::string& cmCustomCommand::GetDepfile() const
  143. {
  144. return this->Depfile;
  145. }
  146. void cmCustomCommand::SetDepfile(const std::string& depfile)
  147. {
  148. this->Depfile = depfile;
  149. }
  150. const std::string& cmCustomCommand::GetJobPool() const
  151. {
  152. return this->JobPool;
  153. }
  154. void cmCustomCommand::SetJobPool(const std::string& job_pool)
  155. {
  156. this->JobPool = job_pool;
  157. }
  158. bool cmCustomCommand::GetJobserverAware() const
  159. {
  160. return this->JobserverAware;
  161. }
  162. void cmCustomCommand::SetJobserverAware(bool b)
  163. {
  164. this->JobserverAware = b;
  165. }
  166. #define DEFINE_CC_POLICY_ACCESSOR(P) \
  167. cmPolicies::PolicyStatus cmCustomCommand::Get##P##Status() const \
  168. { \
  169. return this->P##Status; \
  170. }
  171. CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DEFINE_CC_POLICY_ACCESSOR)
  172. #undef DEFINE_CC_POLICY_ACCESSOR
  173. void cmCustomCommand::RecordPolicyValues(const cmStateSnapshot& snapshot)
  174. {
  175. #define SET_CC_POLICY(P) this->P##Status = snapshot.GetPolicy(cmPolicies::P);
  176. CM_FOR_EACH_CUSTOM_COMMAND_POLICY(SET_CC_POLICY)
  177. #undef SET_CC_POLICY
  178. }
  179. const std::string& cmCustomCommand::GetTarget() const
  180. {
  181. return this->Target;
  182. }
  183. void cmCustomCommand::SetTarget(const std::string& target)
  184. {
  185. this->Target = target;
  186. }