cmCustomCommand.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 "cmCustomCommandLines.h"
  7. #include "cmListFileCache.h"
  8. #include <string>
  9. #include <utility>
  10. #include <vector>
  11. class cmMakefile;
  12. class cmImplicitDependsList
  13. : public std::vector<std::pair<std::string, std::string>>
  14. {
  15. };
  16. /** \class cmCustomCommand
  17. * \brief A class to encapsulate a custom command
  18. *
  19. * cmCustomCommand encapsulates the properties of a custom command
  20. */
  21. class cmCustomCommand
  22. {
  23. public:
  24. /** Main constructor specifies all information for the command. */
  25. cmCustomCommand(cmMakefile const* mf, std::vector<std::string> outputs,
  26. std::vector<std::string> byproducts,
  27. std::vector<std::string> depends,
  28. cmCustomCommandLines commandLines, const char* comment,
  29. const char* workingDirectory);
  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. /** Append to the list of command lines. */
  46. void AppendCommands(const cmCustomCommandLines& commandLines);
  47. /** Append to the list of dependencies. */
  48. void AppendDepends(const std::vector<std::string>& depends);
  49. /** Set/Get whether old-style escaping should be used. */
  50. bool GetEscapeOldStyle() const;
  51. void SetEscapeOldStyle(bool b);
  52. /** Set/Get whether the build tool can replace variables in
  53. arguments to the command. */
  54. bool GetEscapeAllowMakeVars() const;
  55. void SetEscapeAllowMakeVars(bool b);
  56. /** Backtrace of the command that created this custom command. */
  57. cmListFileBacktrace const& GetBacktrace() const;
  58. void SetImplicitDepends(cmImplicitDependsList const&);
  59. void AppendImplicitDepends(cmImplicitDependsList const&);
  60. cmImplicitDependsList const& GetImplicitDepends() const;
  61. /** Set/Get whether this custom command should be given access to the
  62. real console (if possible). */
  63. bool GetUsesTerminal() const;
  64. void SetUsesTerminal(bool b);
  65. /** Set/Get whether lists in command lines should be expanded. */
  66. bool GetCommandExpandLists() const;
  67. void SetCommandExpandLists(bool b);
  68. /** Set/Get the depfile (used by the Ninja generator) */
  69. const std::string& GetDepfile() const;
  70. void SetDepfile(const std::string& depfile);
  71. /** Set/Get the job_pool (used by the Ninja generator) */
  72. const std::string& GetJobPool() const;
  73. void SetJobPool(const std::string& job_pool);
  74. private:
  75. std::vector<std::string> Outputs;
  76. std::vector<std::string> Byproducts;
  77. std::vector<std::string> Depends;
  78. cmCustomCommandLines CommandLines;
  79. cmListFileBacktrace Backtrace;
  80. cmImplicitDependsList ImplicitDepends;
  81. std::string Comment;
  82. std::string WorkingDirectory;
  83. std::string Depfile;
  84. std::string JobPool;
  85. bool HaveComment = false;
  86. bool EscapeAllowMakeVars = false;
  87. bool EscapeOldStyle = true;
  88. bool UsesTerminal = false;
  89. bool CommandExpandLists = false;
  90. };
  91. #endif