cmCustomCommand.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 cmCustomCommand
  13. * \brief A class to encapsulate a custom command
  14. *
  15. * cmCustomCommand encapsulates the properties of a custom command
  16. */
  17. class cmCustomCommand
  18. {
  19. public:
  20. /** Default and copy constructors for STL containers. */
  21. cmCustomCommand();
  22. /** Main constructor specifies all information for the command. */
  23. cmCustomCommand(cmMakefile const* mf,
  24. const std::vector<std::string>& outputs,
  25. const std::vector<std::string>& byproducts,
  26. const std::vector<std::string>& depends,
  27. const cmCustomCommandLines& commandLines,
  28. const char* comment, const char* workingDirectory);
  29. /** Get the output file produced by the command. */
  30. const std::vector<std::string>& GetOutputs() const;
  31. /** Get the extra files produced by the command. */
  32. const std::vector<std::string>& GetByproducts() const;
  33. /** Get the vector that holds the list of dependencies. */
  34. const std::vector<std::string>& GetDepends() const;
  35. /** Get the working directory. */
  36. std::string const& GetWorkingDirectory() const
  37. {
  38. return this->WorkingDirectory;
  39. }
  40. /** Get the list of command lines. */
  41. const cmCustomCommandLines& GetCommandLines() const;
  42. /** Get the comment string for the command. */
  43. const char* GetComment() const;
  44. /** Append to the list of command lines. */
  45. void AppendCommands(const cmCustomCommandLines& commandLines);
  46. /** Append to the list of dependencies. */
  47. void AppendDepends(const std::vector<std::string>& depends);
  48. /** Set/Get whether old-style escaping should be used. */
  49. bool GetEscapeOldStyle() const;
  50. void SetEscapeOldStyle(bool b);
  51. /** Set/Get whether the build tool can replace variables in
  52. arguments to the command. */
  53. bool GetEscapeAllowMakeVars() const;
  54. void SetEscapeAllowMakeVars(bool b);
  55. /** Backtrace of the command that created this custom command. */
  56. cmListFileBacktrace const& GetBacktrace() const;
  57. typedef std::pair<std::string, std::string> ImplicitDependsPair;
  58. class ImplicitDependsList : public std::vector<ImplicitDependsPair>
  59. {
  60. };
  61. void SetImplicitDepends(ImplicitDependsList const&);
  62. void AppendImplicitDepends(ImplicitDependsList const&);
  63. ImplicitDependsList const& GetImplicitDepends() const;
  64. /** Set/Get whether this custom command should be given access to the
  65. real console (if possible). */
  66. bool GetUsesTerminal() const;
  67. void SetUsesTerminal(bool b);
  68. /** Set/Get whether lists in command lines should be expanded. */
  69. bool GetCommandExpandLists() const;
  70. void SetCommandExpandLists(bool b);
  71. /** Set/Get the depfile (used by the Ninja generator) */
  72. const std::string& GetDepfile() const;
  73. void SetDepfile(const std::string& depfile);
  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. ImplicitDependsList ImplicitDepends;
  81. std::string Comment;
  82. std::string WorkingDirectory;
  83. std::string Depfile;
  84. bool HaveComment;
  85. bool EscapeAllowMakeVars;
  86. bool EscapeOldStyle;
  87. bool UsesTerminal;
  88. bool CommandExpandLists;
  89. };
  90. #endif