cmCustomCommand.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmCustomCommand_h
  4. #define cmCustomCommand_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <string>
  7. #include <utility>
  8. #include <vector>
  9. #include "cmCustomCommandLines.h"
  10. #include "cmListFileCache.h"
  11. class cmImplicitDependsList
  12. : public std::vector<std::pair<std::string, std::string>>
  13. {
  14. };
  15. /** \class cmCustomCommand
  16. * \brief A class to encapsulate a custom command
  17. *
  18. * cmCustomCommand encapsulates the properties of a custom command
  19. */
  20. class cmCustomCommand
  21. {
  22. public:
  23. /** Main constructor specifies all information for the command. */
  24. cmCustomCommand(std::vector<std::string> outputs,
  25. std::vector<std::string> byproducts,
  26. std::vector<std::string> depends,
  27. cmCustomCommandLines commandLines, cmListFileBacktrace lfbt,
  28. const char* comment, const char* workingDirectory,
  29. bool stdPipesUTF8);
  30. /** Get the output file produced by the command. */
  31. const std::vector<std::string>& GetOutputs() const;
  32. /** Get the extra files produced by the command. */
  33. const std::vector<std::string>& GetByproducts() const;
  34. /** Get the vector that holds the list of dependencies. */
  35. const std::vector<std::string>& GetDepends() const;
  36. /** Get the working directory. */
  37. std::string const& GetWorkingDirectory() const
  38. {
  39. return this->WorkingDirectory;
  40. }
  41. /** Get the list of command lines. */
  42. const cmCustomCommandLines& GetCommandLines() const;
  43. /** Get the comment string for the command. */
  44. const char* GetComment() const;
  45. /** Get a value indicating if the command uses UTF-8 output pipes. */
  46. bool GetStdPipesUTF8() const { return this->StdPipesUTF8; }
  47. /** Append to the list of command lines. */
  48. void AppendCommands(const cmCustomCommandLines& commandLines);
  49. /** Append to the list of dependencies. */
  50. void AppendDepends(const std::vector<std::string>& depends);
  51. /** Set/Get whether old-style escaping should be used. */
  52. bool GetEscapeOldStyle() const;
  53. void SetEscapeOldStyle(bool b);
  54. /** Set/Get whether the build tool can replace variables in
  55. arguments to the command. */
  56. bool GetEscapeAllowMakeVars() const;
  57. void SetEscapeAllowMakeVars(bool b);
  58. /** Backtrace of the command that created this custom command. */
  59. cmListFileBacktrace const& GetBacktrace() const;
  60. void SetImplicitDepends(cmImplicitDependsList const&);
  61. void AppendImplicitDepends(cmImplicitDependsList const&);
  62. cmImplicitDependsList const& GetImplicitDepends() const;
  63. /** Set/Get whether this custom command should be given access to the
  64. real console (if possible). */
  65. bool GetUsesTerminal() const;
  66. void SetUsesTerminal(bool b);
  67. /** Set/Get whether lists in command lines should be expanded. */
  68. bool GetCommandExpandLists() const;
  69. void SetCommandExpandLists(bool b);
  70. /** Set/Get the depfile (used by the Ninja generator) */
  71. const std::string& GetDepfile() const;
  72. void SetDepfile(const std::string& depfile);
  73. /** Set/Get the job_pool (used by the Ninja generator) */
  74. const std::string& GetJobPool() const;
  75. void SetJobPool(const std::string& job_pool);
  76. private:
  77. std::vector<std::string> Outputs;
  78. std::vector<std::string> Byproducts;
  79. std::vector<std::string> Depends;
  80. cmCustomCommandLines CommandLines;
  81. cmListFileBacktrace Backtrace;
  82. cmImplicitDependsList ImplicitDepends;
  83. std::string Comment;
  84. std::string WorkingDirectory;
  85. std::string Depfile;
  86. std::string JobPool;
  87. bool HaveComment = false;
  88. bool EscapeAllowMakeVars = false;
  89. bool EscapeOldStyle = true;
  90. bool UsesTerminal = false;
  91. bool CommandExpandLists = false;
  92. bool StdPipesUTF8 = false;
  93. };
  94. #endif